add missing check for BN_mod_inverse
authorMansour Ahmadi <m.ahmadi@northeastern.edu>
Tue, 11 Dec 2018 20:48:08 +0000 (15:48 -0500)
committerMatt Caswell <matt@openssl.org>
Thu, 13 Dec 2018 09:59:10 +0000 (09:59 +0000)
Fixes #7650

Reviewed-by: Kurt Roeckx <kurt@roeckx.be>
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/7876)

(cherry picked from commit 55833a8de70589a5000044b6291e190f5a3826ae)

crypto/rsa/rsa_x931g.c

index 3563670..15e40e8 100644 (file)
@@ -128,6 +128,8 @@ int RSA_X931_derive_ex(RSA *rsa, BIGNUM *p1, BIGNUM *p2, BIGNUM *q1,
 
     /* calculate inverse of q mod p */
     rsa->iqmp = BN_mod_inverse(NULL, rsa->q, rsa->p, ctx2);
+    if (rsa->iqmp == NULL)
+        goto err;
 
     ret = 1;
  err: