]> 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:11:37 +0000 (11:11 +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)

(cherry picked from commit a0238b7ed87998c48b1c92bad7fa82dcbba507f9)

crypto/bn/bn_exp.c

index 9531acfc3c94848a177c5938e4b98a651f44b431..451e88ac3c5e885f6b21ef13a3421c0d1a6190fb 100644 (file)
@@ -188,13 +188,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))