Submitted by: Peter Gutmann <pgut001@cs.auckland.ac.nz>
authorDr. Stephen Henson <steve@openssl.org>
Wed, 17 Jun 2009 11:25:42 +0000 (11:25 +0000)
committerDr. Stephen Henson <steve@openssl.org>
Wed, 17 Jun 2009 11:25:42 +0000 (11:25 +0000)
Approved by: steve@openssl.org

Check return values for NULL in case of malloc failure.

crypto/bn/bn_div.c
crypto/bn/bn_exp.c

index 6db472f8c321ec162433577540ad73e084be2d3f..899d07ca2420e208ca893e52bf8ce46138744313 100644 (file)
@@ -229,7 +229,8 @@ int BN_div(BIGNUM *dv, BIGNUM *rm, const BIGNUM *num, const BIGNUM *divisor,
        if (dv == NULL)
                res=BN_CTX_get(ctx);
        else    res=dv;
-       if (sdiv == NULL || res == NULL) goto err;
+       if (sdiv == NULL || res == NULL || tmp == NULL || snum == NULL)
+               goto err;
 
        /* First we normalise the numbers */
        norm_shift=BN_BITS2-((BN_num_bits(divisor))%BN_BITS2);
index 70a33f0d936c81fab3f6a77e411f7e354c652edc..d9b6c737fc82f5f5f8c4bc9a5d7ba23ee8627c73 100644 (file)
@@ -134,7 +134,8 @@ int BN_exp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
                rr = BN_CTX_get(ctx);
        else
                rr = r;
-       if ((v = BN_CTX_get(ctx)) == NULL) goto err;
+       v = BN_CTX_get(ctx);
+       if (rr == NULL || v == NULL) goto err;
 
        if (BN_copy(v,a) == NULL) goto err;
        bits=BN_num_bits(p);