]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix Coverity 1201763 uninitialised pointer read
authorPauli <pauli@openssl.org>
Wed, 16 Mar 2022 02:48:27 +0000 (13:48 +1100)
committerPauli <pauli@openssl.org>
Wed, 23 Mar 2022 00:10:32 +0000 (11:10 +1100)
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/17890)

crypto/bn/bn_exp.c

index bb20e1683e03d760837ac582f62570d287592134..9b6f18a70acfd12364ae4f33591ac8d893598a03 100644 (file)
@@ -187,13 +187,14 @@ int BN_mod_exp_recp(BIGNUM *r, const BIGNUM *a, const BIGNUM *p,
         return ret;
     }
 
+    BN_RECP_CTX_init(&recp);
+
     BN_CTX_start(ctx);
     aa = BN_CTX_get(ctx);
     val[0] = BN_CTX_get(ctx);
     if (val[0] == NULL)
         goto err;
 
-    BN_RECP_CTX_init(&recp);
     if (m->neg) {
         /* ignore sign of 'm' */
         if (!BN_copy(aa, m))