diff options
author | Bernd Edlinger <bernd.edlinger@hotmail.de> | 2022-11-16 12:32:06 +0100 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-12-16 19:05:37 +0100 |
commit | 68cec7e9d31fdf05b82a627a82398d8cfb0b915c (patch) | |
tree | 230b344eb4f6feebb6246cf30d27669fa4f083a4 | |
parent | 31efcf2c872f8f4d09ad5209ccbf1ada73436775 (diff) |
Fix a memory leak in rsa_priv_encode
If PKCS8_pkey_set0 fails, the memory in rk need to be clear freed
otherwise it is owned by the PKCS8_PRIV_KEY_INFO.
Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Todd Short <todd.short@me.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19694)
-rw-r--r-- | crypto/rsa/rsa_ameth.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/crypto/rsa/rsa_ameth.c b/crypto/rsa/rsa_ameth.c index fb045544a8..2c9c46ea53 100644 --- a/crypto/rsa/rsa_ameth.c +++ b/crypto/rsa/rsa_ameth.c @@ -172,6 +172,7 @@ static int rsa_priv_encode(PKCS8_PRIV_KEY_INFO *p8, const EVP_PKEY *pkey) strtype, str, rk, rklen)) { RSAerr(RSA_F_RSA_PRIV_ENCODE, ERR_R_MALLOC_FAILURE); ASN1_STRING_free(str); + OPENSSL_clear_free(rk, rklen); return 0; } |