aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTomas Mraz <[email protected]>2026-10-06 18:44:19 +0200
committerTomas Mraz <[email protected]>2026-10-07 09:39:25 +0200
commit68c40c2c89812a1ecfe12935b8a6a31cfb5c1ff7 (patch)
treee25005c83aa762dd0a6b4d7400ed475335768395
parentRevert "Don't let stderr block when filling up." (diff)
downloadopenssl-68c40c2c89812a1ecfe12935b8a6a31cfb5c1ff7.tar.gz
openssl-68c40c2c89812a1ecfe12935b8a6a31cfb5c1ff7.zip
rsa_multiprime_keygen(): Fix leak of tmp if stack insertion fails
Reviewed-by: Daniel Kubec <[email protected]> Reviewed-by: Richard Levitte <[email protected]> Reviewed-by: Milan Broz <[email protected]> Reviewed-by: Bob Beck <[email protected]> Merge-date: Wed Oct 7 07:39:03 2026 Merged-from: https://github.com/openssl/openssl/pull/33129 (cherry picked from commit 35b8874b1d45aed1a5a604cca75d7af3c1c72067)
-rw-r--r--crypto/rsa/rsa_gen.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/crypto/rsa/rsa_gen.c b/crypto/rsa/rsa_gen.c
index 0d9b4fc1622..c1d0ce0de75 100644
--- a/crypto/rsa/rsa_gen.c
+++ b/crypto/rsa/rsa_gen.c
@@ -450,8 +450,10 @@ static int rsa_multiprime_keygen(RSA *rsa, int bits, int primes,
tmp = BN_dup(prime);
if (tmp == NULL)
goto err;
- if (!sk_BIGNUM_insert(factors, tmp, sk_BIGNUM_num(factors)))
+ if (!sk_BIGNUM_insert(factors, tmp, sk_BIGNUM_num(factors))) {
+ BN_clear_free(tmp);
goto err;
+ }
continue;
}
@@ -520,8 +522,10 @@ static int rsa_multiprime_keygen(RSA *rsa, int bits, int primes,
tmp = BN_dup(prime);
if (tmp == NULL)
goto err;
- if (!sk_BIGNUM_insert(factors, tmp, sk_BIGNUM_num(factors)))
+ if (!sk_BIGNUM_insert(factors, tmp, sk_BIGNUM_num(factors))) {
+ BN_clear_free(tmp);
goto err;
+ }
}
if (BN_cmp(rsa->p, rsa->q) < 0) {