Merge in recent changes from 0.9.6-stable
authorRichard Levitte <levitte@openssl.org>
Thu, 30 May 2002 17:18:58 +0000 (17:18 +0000)
committerRichard Levitte <levitte@openssl.org>
Thu, 30 May 2002 17:18:58 +0000 (17:18 +0000)
25 files changed:
Configure
Makefile.org
TABLE
apps/x509.c
crypto/asn1/a_enum.c
crypto/asn1/a_int.c
crypto/asn1/a_set.c
crypto/asn1/d2i_dhp.c
crypto/asn1/d2i_dsap.c
crypto/asn1/d2i_r_pr.c
crypto/asn1/x_pubkey.c
crypto/bio/bf_nbio.c
crypto/bn/bn_div.c
crypto/bn/bn_gcd.c
crypto/bn/bn_mont.c
crypto/bn/bn_mul.c
crypto/dsa/dsa_asn1.c
crypto/evp/bio_enc.c
crypto/objects/o_names.c
crypto/objects/obj_dat.c
crypto/pkcs7/pk7_doit.c
crypto/rsa/rsa_eay.c
crypto/txt_db/txt_db.c
crypto/x509v3/v3_ia5.c
util/pod2man.pl

index a9d15a80f7b0691c5f707b338ffc90898f306e52..c76747b039e5e7202d7f4a02a39ebf68213eb4ae 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -182,7 +182,7 @@ my %table=(
 "linux-sparcv8","gcc:-mv8 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8.o::::",
 # it's a real mess with -mcpu=ultrasparc option under Linux, but
 # -Wa,-Av8plus should do the trick no matter what.
-"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DULTRASPARC -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+"linux-sparcv9","gcc:-mcpu=ultrasparc -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -Wa,-Av8plus -DULTRASPARC -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:asm/sparcv8plus.o:::asm/md5-sparcv8plus.o::::::dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 # !!!Folowing can't be even tested yet!!!
 #    We have to wait till 64-bit glibc for SPARC is operational!!!
 #"linux64-sparcv9","sparc64-linux-gcc:-m64 -mcpu=v9 -DB_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall -DULTRASPARC -DBN_DIV2W::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR::::asm/md5-sparcv9.o:",
@@ -345,7 +345,7 @@ my %table=(
 # The intel boxes :-), It would be worth seeing if bsdi-gcc can use the
 # bn86-elf.o file file since it is hand tweaked assembler.
 "linux-elf",   "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::-D_REENTRANT:-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
-"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT:-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC:.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
+"debug-linux-elf","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT:-lefence -ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
 "debug-linux-elf-noefence","gcc:-DBN_DEBUG -DREF_CHECK -DCONF_DEBUG -DBN_CTX_DEBUG -DCRYPTO_MDEBUG -DL_ENDIAN -DTERMIO -g -m486 -Wall::-D_REENTRANT:-ldl:BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_elf_asm}:dlfcn",
 "linux-aout",  "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -m486 -Wall::(unknown)::BN_LLONG ${x86_gcc_des} ${x86_gcc_opts}:${x86_out_asm}",
 "linux-mipsel",   "gcc:-DL_ENDIAN -DTERMIO -O3 -fomit-frame-pointer -Wall::(unknown)::BN_LLONG:::",
@@ -498,7 +498,7 @@ my %table=(
 
 ##### MacOS X (a.k.a. Rhapsody or Darwin) setup
 "rhapsody-ppc-cc","cc:-O3 -DB_ENDIAN::(unknown)::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::",
-"darwin-ppc-cc","cc:-O3 -D_DARWIN -DB_ENDIAN::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::::::::::darwin-shared:-fPIC:.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
+"darwin-ppc-cc","cc:-O3 -D_DARWIN -DB_ENDIAN::-D_REENTRANT::BN_LLONG RC4_CHAR RC4_CHUNK DES_UNROLL BF_PTR:::::::::::darwin-shared:-fPIC::.\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
 
 ##### Sony NEWS-OS 4.x
 "newsos4-gcc","gcc:-O -DB_ENDIAN -DNEWS4::(unknown):-lmld -liberty:BN_LLONG RC4_CHAR RC4_CHUNK DES_PTR DES_RISC1 DES_UNROLL BF_PTR::::",
@@ -1003,13 +1003,21 @@ while (<IN>)
        if ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*$/)
                {
                my $sotmp = $1;
-               s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp/
+               s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp/;
+               }
+       elsif ($shared_extension ne "" && $shared_extension =~ /^\.[^\.]*\.dylib$/)
+               {
+               s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.dylib/;
                }
        elsif ($shared_extension ne "" && $shared_extension =~ /^\.s([ol])\.[^\.]*\.[^\.]*$/)
                {
                my $sotmp = $1;
                s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.s$sotmp.\$(SHLIB_MAJOR) .s$sotmp/;
                }
+       elsif ($shared_extension ne "" && $shared_extension =~ /^\.[^\.]*\.[^\.]*\.dylib$/)
+               {
+               s/^SHARED_LIBS_LINK_EXTS=.*/SHARED_LIBS_LINK_EXTS=.\$(SHLIB_MAJOR).dylib .dylib/;
+               }
        s/^SHARED_LDFLAGS=.*/SHARED_LDFLAGS=$shared_ldflag/;
        print OUT $_."\n";
        }
index fdf95d6d012c99e67154fada298c16ad5b986cd5..8bd0e23e6fc4878cce37c3b89cf4ce5cc164b73e 100644 (file)
@@ -682,8 +682,9 @@ install_docs:
                if [ "$$fn" = "config" ]; then sec=5; else sec=1; fi; \
                echo "installing man$$sec/`basename $$i .pod`.$$sec"; \
                (cd `dirname $$i`; \
-               $(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
-                        --release=$(VERSION) `basename $$i`) \
+               sh -c "`cd ../../util; ./pod2mantest ignore` \
+                       --section=$$sec --center=OpenSSL \
+                       --release=$(VERSION) `basename $$i`") \
                        >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \
        done
        @for i in doc/crypto/*.pod doc/ssl/*.pod; do \
@@ -691,8 +692,9 @@ install_docs:
                if [ "$$fn" = "des_modes" ]; then sec=7; else sec=3; fi; \
                echo "installing man$$sec/`basename $$i .pod`.$$sec"; \
                (cd `dirname $$i`; \
-               $(PERL) ../../util/pod2man.pl --section=$$sec --center=OpenSSL \
-                       --release=$(VERSION) `basename $$i`) \
+               sh -c "`cd ../../util; ./pod2mantest ignore` \
+                       --section=$$sec --center=OpenSSL \
+                       --release=$(VERSION) `basename $$i`") \
                        >  $(INSTALL_PREFIX)$(MANDIR)/man$$sec/`basename $$i .pod`.$$sec; \
        done
 
diff --git a/TABLE b/TABLE
index cce12757cfa4d68c056ba29c2f6ee31b2de5496d..41ff62f615f7f698d5a28d77906dd2961be6f947 100644 (file)
--- a/TABLE
+++ b/TABLE
@@ -1,3 +1,4 @@
+Output of `Configure TABLE':
 
 *** BC-16
 $cc           = bcc
@@ -1099,8 +1100,8 @@ $rc5_obj      =
 $dso_scheme   = 
 $shared_target= darwin-shared
 $shared_cflag = -fPIC
-$shared_ldflag = .$(SHLIB_MAJOR).$(SHLIB_MINOR).dylib
-$shared_extension = 
+$shared_ldflag = 
+$shared_extension = .$(SHLIB_MAJOR).$(SHLIB_MINOR).dylib
 $ranlib       = 
 
 *** debug
@@ -1260,8 +1261,8 @@ $rc5_obj      = asm/r586-elf.o
 $dso_scheme   = dlfcn
 $shared_target= linux-shared
 $shared_cflag = -fPIC
-$shared_ldflag = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
-$shared_extension = 
+$shared_ldflag = 
+$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
 $ranlib       = 
 
 *** debug-linux-elf-noefence
@@ -2479,8 +2480,8 @@ $rc5_obj      =
 $dso_scheme   = dlfcn
 $shared_target= linux-shared
 $shared_cflag = -fPIC
-$shared_ldflag = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
-$shared_extension = 
+$shared_ldflag = 
+$shared_extension = .so.$(SHLIB_MAJOR).$(SHLIB_MINOR)
 $ranlib       = 
 
 *** ncr-scde
@@ -2784,7 +2785,7 @@ $ranlib       =
 
 *** sco5-gcc-shared
 $cc           = gcc
-$cflags       = -O3 -DFILIO_H -fomit-frame-pointer
+$cflags       = -O3 -fomit-frame-pointer
 $unistd       = 
 $thread_cflag = 
 $lflags       = -lsocket -lresolv -lnsl
index 95f05e580c4731c2b2d218f561e8987d69c96723..0833b5453ef4bf76e1db6906a74484823ec33c8a 100644 (file)
@@ -237,7 +237,7 @@ int MAIN(int argc, char **argv)
                else if (strcmp(*argv,"-CAkeyform") == 0)
                        {
                        if (--argc < 1) goto bad;
-                       CAformat=str2fmt(*(++argv));
+                       CAkeyformat=str2fmt(*(++argv));
                        }
                else if (strcmp(*argv,"-days") == 0)
                        {
index 1428d1df7a499c18510ec8e5de8f70f8887f5605..74b1414a91b21ee11c4626914bc3c7f8f7b5088b 100644 (file)
@@ -205,7 +205,17 @@ ASN1_ENUMERATED *BN_to_ASN1_ENUMERATED(BIGNUM *bn, ASN1_ENUMERATED *ai)
        else ret->type=V_ASN1_ENUMERATED;
        j=BN_num_bits(bn);
        len=((j == 0)?0:((j/8)+1));
-       ret->data=(unsigned char *)OPENSSL_malloc(len+4);
+       if (ret->length < len+4)
+               {
+               char *new_data=(char *)OPENSSL_realloc(ret->data, len+4);
+               if (!new_data)
+                       {
+                       ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
+                       goto err;
+                       }
+               ret->data=new_data;
+               }
+
        ret->length=BN_bn2bin(bn,ret->data);
        return(ret);
 err:
index 6f0413f885c16e8297c3fd9a7a25e612bdff23ee..7b39519e5cb9ec8e5f167537145e48ca605a6d6b 100644 (file)
@@ -451,7 +451,16 @@ ASN1_INTEGER *BN_to_ASN1_INTEGER(BIGNUM *bn, ASN1_INTEGER *ai)
        else ret->type=V_ASN1_INTEGER;
        j=BN_num_bits(bn);
        len=((j == 0)?0:((j/8)+1));
-       ret->data=(unsigned char *)OPENSSL_malloc(len+4);
+       if (ret->length < len+4)
+               {
+               char *new_data=(char *)OPENSSL_realloc(ret->data, len+4);
+               if (!new_data)
+                       {
+                       ASN1err(ASN1_F_BN_TO_ASN1_INTEGER,ERR_R_MALLOC_FAILURE);
+                       goto err;
+                       }
+               ret->data=new_data;
+               }
        ret->length=BN_bn2bin(bn,ret->data);
        return(ret);
 err:
index caf5a1419c98cbe201acbacfc8e24b99ecd58eab..5b0938e97b1cce570671103b21c425a8d0cf7fc0 100644 (file)
@@ -116,7 +116,7 @@ int i2d_ASN1_SET(STACK *a, unsigned char **pp, int (*func)(), int ex_tag,
                }
 
         pStart  = p; /* Catch the beg of Setblobs*/
-        rgSetBlob = (MYBLOB *)OPENSSL_malloc( sk_num(a) * sizeof(MYBLOB)); /* In this array
+        if (!(rgSetBlob = (MYBLOB *)OPENSSL_malloc( sk_num(a) * sizeof(MYBLOB)))) return 0; /* In this array
 we will store the SET blobs */
 
         for (i=0; i<sk_num(a); i++)
@@ -133,7 +133,7 @@ SetBlob
  /* Now we have to sort the blobs. I am using a simple algo.
     *Sort ptrs *Copy to temp-mem *Copy from temp-mem to user-mem*/
         qsort( rgSetBlob, sk_num(a), sizeof(MYBLOB), SetBlobCmp);
-        pTempMem = OPENSSL_malloc(totSize);
+        if (!(pTempMem = OPENSSL_malloc(totSize))) return 0;
 
 /* Copy to temp mem */
         p = pTempMem;
index 635ae829db3febf265f1d63b5e21885eb1f8ca82..223ebbbd46d1a6ae9116102b4600b745df0f8bde 100644 (file)
@@ -87,6 +87,7 @@ DH *d2i_DHparams(DH **a, unsigned char **pp, long length)
                }
 
        M_ASN1_BIT_STRING_free(bs);
+       bs = NULL;
 
        M_ASN1_D2I_Finish_2(a);
 
index 9d4dea6145aaef0c0d224b222a2f74efd67d9a1d..a68f35d852bd69bfa0dce68c17d32653ac46d034 100644 (file)
@@ -84,6 +84,7 @@ DSA *d2i_DSAparams(DSA **a, unsigned char **pp, long length)
        if ((ret->g=BN_bin2bn(bs->data,bs->length,ret->g)) == NULL) goto err_bn;
 
        M_ASN1_BIT_STRING_free(bs);
+       bs = NULL;
 
        M_ASN1_D2I_Finish_2(a);
 
index 6c8a45f821faf2f2c2622a59f904515318e07c41..afd5adb1d871124471e48283daa04904c43594c1 100644 (file)
@@ -108,6 +108,7 @@ RSA *d2i_RSAPrivateKey(RSA **a, unsigned char **pp, long length)
                goto err_bn;
 
        M_ASN1_INTEGER_free(bs);
+       bs = NULL;
 
        M_ASN1_D2I_Finish_2(a);
 err_bn:
index 4397a404b56f812426971341ad5472d470d2b140..914bcda689454253c0ee49979f9d446a3afca6db 100644 (file)
@@ -156,7 +156,7 @@ int X509_PUBKEY_set(X509_PUBKEY **x, EVP_PKEY *pkey)
                dsa->write_params=0;
                ASN1_TYPE_free(a->parameter);
                i=i2d_DSAparams(dsa,NULL);
-               p=(unsigned char *)OPENSSL_malloc(i);
+               if ((p=(unsigned char *)OPENSSL_malloc(i)) == NULL) goto err;
                pp=p;
                i2d_DSAparams(dsa,&pp);
                a->parameter=ASN1_TYPE_new();
index 413ef5c4c5e943bb4a342e00872317639c2a7c16..988cd5ae006e64f944e994f91934ab10e232ece1 100644 (file)
@@ -104,7 +104,7 @@ static int nbiof_new(BIO *bi)
        {
        NBIO_TEST *nt;
 
-       nt=(NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST));
+       if (!(nt=(NBIO_TEST *)OPENSSL_malloc(sizeof(NBIO_TEST)))) return(0);
        nt->lrn= -1;
        nt->lwn= -1;
        bi->ptr=(char *)nt;
index 613a2688237a1bf41ad30f0f0019379291f78987..903ab2ee2e61e081574b4ebe33e0d161618a1a9b 100644 (file)
@@ -190,10 +190,10 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
 
        /* First we normalise the numbers */
        norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
-       BN_lshift(sdiv,divisor,norm_shift);
+       if (!(BN_lshift(sdiv,divisor,norm_shift))) goto err;
        sdiv->neg=0;
        norm_shift+=BN_BITS2;
-       BN_lshift(snum,num,norm_shift);
+       if (!(BN_lshift(snum,num,norm_shift))) goto err;
        snum->neg=0;
        div_n=sdiv->top;
        num_n=snum->top;
@@ -315,7 +315,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
                tmp->top=j;
 
                j=wnum.top;
-               BN_sub(&wnum,&wnum,tmp);
+               if (!BN_sub(&wnum,&wnum,tmp)) goto err;
 
                snum->top=snum->top+wnum.top-j;
 
@@ -323,7 +323,7 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
                        {
                        q--;
                        j=wnum.top;
-                       BN_add(&wnum,&wnum,sdiv);
+                       if (!BN_add(&wnum,&wnum,sdiv)) goto err;
                        snum->top+=wnum.top-j;
                        }
                *(resp--)=q;
index 398207196be841403cc5c2b3caf36e9c7cb8e9a4..e8cc6c5cb5df3951863904772aa936dc4e3a1484 100644 (file)
@@ -168,8 +168,8 @@ BIGNUM *BN_mod_inverse(BIGNUM *in, BIGNUM *a, const BIGNUM *n, BN_CTX *ctx)
                R=in;
        if (R == NULL) goto err;
 
-       BN_zero(X);
-       BN_one(Y);
+       if (!BN_zero(X)) goto err;
+       if (!BN_one(Y)) goto err;
        if (BN_copy(A,a) == NULL) goto err;
        if (BN_copy(B,n) == NULL) goto err;
        sign=1;
index 8cf1febaccad8579bcc13d91caf55d520d1c25e1..1daf50783c87a5255293777286c65b3093624e81 100644 (file)
@@ -224,7 +224,7 @@ int BN_from_montgomery(BIGNUM *ret, BIGNUM *a, BN_MONT_CTX *mont,
 
        if (!BN_mul(t1,t2,&mont->N,ctx)) goto err;
        if (!BN_add(t2,a,t1)) goto err;
-       BN_rshift(ret,t2,mont->ri);
+       if (!BN_rshift(ret,t2,mont->ri)) goto err;
 #endif /* MONT_WORD */
 
        if (BN_ucmp(ret, &(mont->N)) >= 0)
@@ -284,8 +284,8 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
                BN_ULONG buf[2];
 
                mont->ri=(BN_num_bits(mod)+(BN_BITS2-1))/BN_BITS2*BN_BITS2;
-               BN_zero(R);
-               BN_set_bit(R,BN_BITS2);                 /* R */
+               if (!(BN_zero(R))) goto err;
+               if (!(BN_set_bit(R,BN_BITS2))) goto err;        /* R */
 
                buf[0]=mod->d[0]; /* tmod = N mod word size */
                buf[1]=0;
@@ -296,36 +296,44 @@ int BN_MONT_CTX_set(BN_MONT_CTX *mont, const BIGNUM *mod, BN_CTX *ctx)
                                                        /* Ri = R^-1 mod N*/
                if ((BN_mod_inverse(&Ri,R,&tmod,ctx)) == NULL)
                        goto err;
-               BN_lshift(&Ri,&Ri,BN_BITS2);            /* R*Ri */
+               /* R*Ri */
+               if (!(BN_lshift(&Ri,&Ri,BN_BITS2))) goto err;
                if (!BN_is_zero(&Ri))
-                       BN_sub_word(&Ri,1);
+                       {
+                       if (!BN_sub_word(&Ri,1)) goto err;
+                       }
                else /* if N mod word size == 1 */
-                       BN_set_word(&Ri,BN_MASK2);  /* Ri-- (mod word size) */
-               BN_div(&Ri,NULL,&Ri,&tmod,ctx); /* Ni = (R*Ri-1)/N,
-                                                * keep only least significant word: */
+                       /* Ri-- (mod word size) */
+                       {
+                       if (!BN_set_word(&Ri,BN_MASK2)) goto err;
+                       }
+               /* Ni = (R*Ri-1)/N, keep only least significant word: */
+                if (!(BN_div(&Ri,NULL,&Ri,&tmod,ctx))) goto err;
                mont->n0=Ri.d[0];
                BN_free(&Ri);
                }
 #else /* !MONT_WORD */
                { /* bignum version */
                mont->ri=BN_num_bits(mod);
-               BN_zero(R);
-               BN_set_bit(R,mont->ri);                 /* R = 2^ri */
+               if (!(BN_zero(R))) goto err;
+               /* R = 2^ri */
+               if (!(BN_set_bit(R,mont->ri))) goto err;
                                                        /* Ri = R^-1 mod N*/
                if ((BN_mod_inverse(&Ri,R,mod,ctx)) == NULL)
                        goto err;
-               BN_lshift(&Ri,&Ri,mont->ri);            /* R*Ri */
-               BN_sub_word(&Ri,1);
+               /* R*Ri */
+               if (!(BN_lshift(&Ri,&Ri,mont->ri))) goto err;
+               if (!(BN_sub_word(&Ri,1))) goto err;
                                                        /* Ni = (R*Ri-1) / N */
-               BN_div(&(mont->Ni),NULL,&Ri,mod,ctx);
+               if (!(BN_div(&(mont->Ni),NULL,&Ri,mod,ctx))) goto err;
                BN_free(&Ri);
                }
 #endif
 
        /* setup RR for conversions */
-       BN_zero(&(mont->RR));
-       BN_set_bit(&(mont->RR),mont->ri*2);
-       BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx);
+       if (!(BN_zero(&(mont->RR)))) goto err;
+       if (!(BN_set_bit(&(mont->RR),mont->ri*2))) goto err;
+       if (!(BN_mod(&(mont->RR),&(mont->RR),&(mont->N),ctx))) goto err;
 
        return(1);
 err:
@@ -336,9 +344,9 @@ BN_MONT_CTX *BN_MONT_CTX_copy(BN_MONT_CTX *to, BN_MONT_CTX *from)
        {
        if (to == from) return(to);
 
-       BN_copy(&(to->RR),&(from->RR));
-       BN_copy(&(to->N),&(from->N));
-       BN_copy(&(to->Ni),&(from->Ni));
+       if (!(BN_copy(&(to->RR),&(from->RR)))) return NULL;
+       if (!(BN_copy(&(to->N),&(from->N)))) return NULL;
+       if (!(BN_copy(&(to->Ni),&(from->Ni)))) return NULL;
        to->ri=from->ri;
        to->n0=from->n0;
        return(to);
index 3e8d8b9567a89af94383b8e6120a78cb060a55a5..90592718d67d250914e42ed07e511d061834261d 100644 (file)
@@ -634,7 +634,7 @@ int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
 
        if ((al == 0) || (bl == 0))
                {
-               BN_zero(r);
+               if (!BN_zero(r)) goto err;
                return(1);
                }
        top=al+bl;
@@ -677,14 +677,14 @@ int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
                {
                if (i == 1 && !BN_get_flags(b,BN_FLG_STATIC_DATA))
                        {
-                       bn_wexpand(b,al);
+                       if (bn_wexpand(b,al) == NULL) goto err;
                        b->d[bl]=0;
                        bl++;
                        i--;
                        }
                else if (i == -1 && !BN_get_flags(a,BN_FLG_STATIC_DATA))
                        {
-                       bn_wexpand(a,bl);
+                       if (bn_wexpand(a,bl) == NULL) goto err;
                        a->d[al]=0;
                        al++;
                        i++;
@@ -699,16 +699,16 @@ int BN_mul(BIGNUM *r, BIGNUM *a, BIGNUM *b, BN_CTX *ctx)
                        t = BN_CTX_get(ctx);
                        if (al == j) /* exact multiple */
                                {
-                               bn_wexpand(t,k*2);
-                               bn_wexpand(rr,k*2);
+                               if (bn_wexpand(t,k*2) == NULL) goto err;
+                               if (bn_wexpand(rr,k*2) == NULL) goto err;
                                bn_mul_recursive(rr->d,a->d,b->d,al,t->d);
                                }
                        else
                                {
-                               bn_wexpand(a,k);
-                               bn_wexpand(b,k);
-                               bn_wexpand(t,k*4);
-                               bn_wexpand(rr,k*4);
+                               if (bn_wexpand(a,k) == NULL ) goto err;
+                               if (bn_wexpand(b,k) == NULL ) goto err;
+                               if (bn_wexpand(t,k*4) == NULL ) goto err;
+                               if (bn_wexpand(rr,k*4) == NULL ) goto err;
                                for (i=a->top; i<k; i++)
                                        a->d[i]=0;
                                for (i=b->top; i<k; i++)
index a76c8f7c7eb389e3d34a3bfb67b83dceda456f1e..649d17ebe9cd6fd725dec5e30f1e4c98e52db60d 100644 (file)
@@ -84,6 +84,7 @@ DSA_SIG *d2i_DSA_SIG(DSA_SIG **a, unsigned char **pp, long length)
        if ((ret->s=BN_bin2bn(bs->data,bs->length,ret->s)) == NULL)
                goto err_bn;
        M_ASN1_BIT_STRING_free(bs);
+       bs = NULL;
        M_ASN1_D2I_Finish_2(a);
 
 err_bn:
index 831c71a2b5988f598aad4efdd8ae20729404a07f..c425a971afb2a4637573880d1c8409bdae0fbc8b 100644 (file)
@@ -106,8 +106,8 @@ static int enc_new(BIO *bi)
        BIO_ENC_CTX *ctx;
 
        ctx=(BIO_ENC_CTX *)OPENSSL_malloc(sizeof(BIO_ENC_CTX));
-       EVP_CIPHER_CTX_init(&ctx->cipher);
        if (ctx == NULL) return(0);
+       EVP_CIPHER_CTX_init(&ctx->cipher);
 
        ctx->buf_len=0;
        ctx->buf_off=0;
index dca988230e8c69ac4a382d8c2331ee23895bc5f2..5eaf95b12f978c1b5eadf90410b2a6fd70361e80 100644 (file)
@@ -61,6 +61,8 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
                {
                MemCheck_off();
                name_funcs = OPENSSL_malloc(sizeof(NAME_FUNCS));
+               MemCheck_on();
+               if (!name_funcs) return(0);
                name_funcs->hash_func = lh_strhash;
                name_funcs->cmp_func = (int (*)())strcmp;
                name_funcs->free_func = 0; /* NULL is often declared to
@@ -68,6 +70,7 @@ int OBJ_NAME_new_index(unsigned long (*hash_func)(const char *),
                                            * to Compaq C is not really
                                            * compatible with a function
                                            * pointer.  -- Richard Levitte*/
+               MemCheck_off();
                sk_NAME_FUNCS_push(name_funcs_stack,name_funcs);
                MemCheck_on();
                }
index d802c4d09cdfc294f3b9c43ee4f284a04e9c6e0b..95ea4bfed304fe854ccac80b90d735b6db67be13 100644 (file)
@@ -228,7 +228,7 @@ int OBJ_add_object(ASN1_OBJECT *obj)
        if (added == NULL)
                if (!init_added()) return(0);
        if ((o=OBJ_dup(obj)) == NULL) goto err;
-       ao[ADDED_NID]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ));
+       if (!(ao[ADDED_NID]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ)))) goto err;
        if ((o->length != 0) && (obj->data != NULL))
                ao[ADDED_DATA]=(ADDED_OBJ *)OPENSSL_malloc(sizeof(ADDED_OBJ));
        if (o->sn != NULL)
index b209a86ea0cdbe4fe54c9f6f2d51c3c8ade6828a..a45cf76c68730a9b76ce242e73e6628383f49b76 100644 (file)
@@ -621,7 +621,7 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
                                x=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL,
                                           i2d_X509_ATTRIBUTE,
                                           V_ASN1_SET,V_ASN1_UNIVERSAL,IS_SET);
-                               pp=(unsigned char *)OPENSSL_malloc(x);
+                               if (!(pp=(unsigned char *)OPENSSL_malloc(x))) goto err;
                                p=pp;
                                i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p,
                                           i2d_X509_ATTRIBUTE,
@@ -817,7 +817,7 @@ for (ii=0; ii<md_len; ii++) printf("%02X",md_dat[ii]); printf(" calc\n");
                 */
                i=i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,NULL,i2d_X509_ATTRIBUTE,
                        V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);
-               pp=OPENSSL_malloc(i);
+               if (!(pp=OPENSSL_malloc(i))) goto err;
                p=pp;
                i2d_ASN1_SET_OF_X509_ATTRIBUTE(sk,&p,i2d_X509_ATTRIBUTE,
                        V_ASN1_SET,V_ASN1_UNIVERSAL, IS_SEQUENCE);
index f4e96c987a24ab9e7509caddef09761628a52e2c..46538926a3dda4cf984d9deb95c2d0a7eca81e90 100644 (file)
@@ -486,11 +486,11 @@ static int RSA_eay_mod_exp(BIGNUM *r0, BIGNUM *I, RSA *rsa)
        int ret=0;
        BN_CTX *ctx;
 
-       meth = ENGINE_get_RSA(rsa->engine);
-       if ((ctx=BN_CTX_new()) == NULL) goto err;
        BN_init(&m1);
        BN_init(&r1);
        BN_init(&vrfy);
+       meth = ENGINE_get_RSA(rsa->engine);
+       if ((ctx=BN_CTX_new()) == NULL) goto err;
 
        if (rsa->flags & RSA_FLAG_CACHE_PRIVATE)
                {
index 3b04fe280c37888c32e57895ebedfa6ec4b4d10f..92fcbde47fafee8b77ba4c8118d349232a789361 100644 (file)
@@ -122,7 +122,7 @@ TXT_DB *TXT_DB_read(BIO *in, int num)
                else
                        {
                        buf->data[offset-1]='\0'; /* blat the '\n' */
-                       p=(char *)OPENSSL_malloc(add+offset);
+                       if (!(p=(char *)OPENSSL_malloc(add+offset))) goto err;
                        offset=0;
                        }
                pp=(char **)p;
index f3bba382693176d066656a7f95ad28f371f164ef..f9414456de27016159bf6da9ba580759b48e4ee8 100644 (file)
@@ -82,7 +82,7 @@ static char *i2s_ASN1_IA5STRING(X509V3_EXT_METHOD *method,
 {
        char *tmp;
        if(!ia5 || !ia5->length) return NULL;
-       tmp = OPENSSL_malloc(ia5->length + 1);
+       if (!(tmp = OPENSSL_malloc(ia5->length + 1))) return NULL;
        memcpy(tmp, ia5->data, ia5->length);
        tmp[ia5->length] = 0;
        return tmp;
index c6b64add602d7977c13b0675edc7b3f6664425c1..657e4e264e07dab613f489fe0601d86daec725ff 100755 (executable)
@@ -416,8 +416,8 @@ if ($name ne 'something') {
                        warn "$0: Improper man page - malformed NAME header in paragraph $. of $ARGV[0]\n"
                    }
                    else {
-                       $n[0] =~ s/\n/ /;
-                       $n[1] =~ s/\n/ /;
+                       $n[0] =~ s/\n/ /g;
+                       $n[1] =~ s/\n/ /g;
                        %namedesc = @n;
                    }
                }