BN_GF2m_mod_inv(): check bn_wexpand return value
authorPascal Cuoq <cuoq@trust-in-soft.com>
Mon, 12 Oct 2015 10:19:19 +0000 (12:19 +0200)
committerKurt Roeckx <kurt@roeckx.be>
Thu, 29 Oct 2015 19:34:24 +0000 (20:34 +0100)
Signed-off-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Rich Salz <rsalz@akamai.com>
MR #1276, RT #4107

crypto/bn/bn_gf2m.c

index 3b6c883c04b954c3dcb8af784135104c6bb73752..11d00c6cdaae6879d33797d55cb54d5192c27f2e 100644 (file)
@@ -697,18 +697,21 @@ int BN_GF2m_mod_inv(BIGNUM *r, const BIGNUM *a, const BIGNUM *p, BN_CTX *ctx)
         int top = p->top;
         BN_ULONG *udp, *bdp, *vdp, *cdp;
 
-        bn_wexpand(u, top);
+        if (!bn_wexpand(u, top))
+            goto err;
         udp = u->d;
         for (i = u->top; i < top; i++)
             udp[i] = 0;
         u->top = top;
-        bn_wexpand(b, top);
+        if (!bn_wexpand(b, top))
+          goto err;
         bdp = b->d;
         bdp[0] = 1;
         for (i = 1; i < top; i++)
             bdp[i] = 0;
         b->top = top;
-        bn_wexpand(c, top);
+        if (!bn_wexpand(c, top))
+          goto err;
         cdp = c->d;
         for (i = 0; i < top; i++)
             cdp[i] = 0;