Hello!

a_dup.c contains following code.

1>    i=(long)i2d(x,NULL);
2>    b=(unsigned char *)OPENSSL_malloc((unsigned int)i+10);
3>    if (b == NULL)
4>        { ASN1err(ASN1_F_ASN1_DUP,ERR_R_MALLOC_FAILURE); return(NULL); }
5>    p= b;
6>    i=i2d(x,&p);
7>    p= b;
8>    ret=d2i(NULL,&p,i);

Note that on the line 1 length for der-encoded buffer is asked and stored
into variable i. On the line 6 this variable i is modified again. This
should be OK - Noone has modified the structure x inbetween and the return
value of i2d should be same. In a real life this is not the case. For
example following macros fail to work together:

M_ASN1_I2D_vars - sets variables r and ret zero

M_ASN1_I2D_len_EXP_opt - stores the length of der-buffer in variable ret

M_ASN1_I2D_put_EXP_opt - doesn't modify variables r and ret

M_ASN1_I2D_finish - returns value kept in variable r (this is not
modified by previous macros and thus zero)

So one of the two is broken - those macros (asn1_mac.h) or a_dup.c

For my own purposes I rewrote line 6

6> i2d(x, &p);

I have checked the length before once so no need to check it again.

        Sven Heiberg


------------------------------------------------------------------------------
OpenSSL self-test report:

OpenSSL version:  0.9.6
Last change:      In ssl23_get_client_hello, generate an error message wh...
Options:          --prefix=/usr/local/openssl-0.9.6
OS (uname):       Linux elevant 2.2.16-3 #1 Mon Jun 19 19:11:44 EDT 2000 i686 unknown
OS (config):      i686-whatever-linux2
Target (default): ??
Target:           linux-elf
Compiler:         gcc version 2.95.3 20010125 (prerelease)

Test passed.

______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to