[EMAIL PROTECTED] wrote:
>
> levitte 13-Dec-2000 18:15:05
>
>
> Now, if someone could explain to me why OBJ_dup() cheats...
>
> Revision Changes Path
> 1.33 +9 -8 openssl/crypto/objects/objects.h
> 1.6 +4 -3 openssl/crypto/objects/obj_lib.c
> 1.20 +12 -11 openssl/crypto/objects/obj_dat.c
> 1.21 +4 -4 openssl/crypto/objects/o_names.c
>
>
> Index: obj_lib.c
> ===================================================================
> RCS file: /e/openssl/cvs/openssl/crypto/objects/obj_lib.c,v
> retrieving revision 1.5
> retrieving revision 1.6
> diff -u -r1.5 -r1.6
> --- obj_lib.c 2000/06/01 22:18:22 1.5
> +++ obj_lib.c 2000/12/13 17:14:49 1.6
> @@ -62,7 +62,7 @@
> #include <openssl/objects.h>
> #include <openssl/buffer.h>
>
> -ASN1_OBJECT *OBJ_dup(ASN1_OBJECT *o)
> +ASN1_OBJECT *OBJ_dup(const ASN1_OBJECT *o)
> {
> ASN1_OBJECT *r;
> int i;
> @@ -70,7 +70,8 @@
>
> if (o == NULL) return(NULL);
> if (!(o->flags & ASN1_OBJECT_FLAG_DYNAMIC))
> - return(o);
> + return((ASN1_OBJECT *)o); /* XXX: ugh! Why? What kind of
> + duplication is this??? */
>
> r=ASN1_OBJECT_new();
> if (r == NULL)
> @@ -116,7 +117,7 @@
> return(NULL);
> }
>
If ASN1_OBJECT_FLAG_DYNAMIC isn't set then the ASN1_OBJECT structure is
form the static list of the "standard objects" OpenSSL understands. As
such it doesn't need to be dup'ed.
The standard functions that modify ASN1_OBJECTs (hopefully) check this
flag carefully if an attempt is made to modify it.
Steve.
--
Dr Stephen N. Henson. http://www.drh-consultancy.demon.co.uk/
Personal Email: [EMAIL PROTECTED]
Senior crypto engineer, Celo Communications: http://www.celocom.com/
Core developer of the OpenSSL project: http://www.openssl.org/
Business Email: [EMAIL PROTECTED] PGP key: via homepage.
______________________________________________________________________
OpenSSL Project http://www.openssl.org
Development Mailing List [EMAIL PROTECTED]
Automated List Manager [EMAIL PROTECTED]