In crypto/asn1/a_int.c part of the recent bugfix for 0.9.6e the code
changes from using OPENSSL_malloc() to OPENSSL_realloc() (which seem
to mostly be wrappers round malloc/realloc).

On new systems passing NULL to realloc() makes it act like malloc(),
but on older ones (like sunos4) it doesn't (we get an error instead).

Here is a short patch:

--cut-here--
--- crypto/asn1/a_int.c.orig    Wed Jun  5 14:12:55 2002
+++ crypto/asn1/a_int.c Wed Jul 31 20:11:24 2002
@@ -453,7 +453,15 @@
        len=((j == 0)?0:((j/8)+1));
        if (ret->length < len+4)
                {
-               unsigned char *new_data= OPENSSL_realloc(ret->data, len+4);
+               unsigned char *new_data;
+               
+               /* Needed for older realloc() (e.g. on SunOS4) which
+                  fails if ptr is null.  2002-07-31 JSP */
+               if (ret->data == NULL) {
+                 new_data = OPENSSL_malloc(len+4);
+               } else {
+                 new_data = OPENSSL_realloc(ret->data, len+4);
+               }
                if (!new_data)
                        {
                        ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
--cut-here--

Otherwise the first attempt to allocate data (with this routine at
least), will fail (test/testca fails on such systems in the -sign
test).

Looking through the rest of the 0.9.6e patch I can't see any other
cases where realloc() is called like this but I might well have missed
some.  I'm hoping that someone who understands the code better will
confirm/check this.

 -- Jon

-- 
Jon Peatfield,  DAMTP,  Computer Officer,   University of Cambridge
Telephone: +44 1223  3 37852    Mail: [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [EMAIL PROTECTED]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to