diff options
author | Milan Broz <gmazyland@gmail.com> | 2022-10-29 11:46:34 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2022-11-10 18:11:59 +0100 |
commit | 60d391b6f0178e1f1afac242db460a14590bc03e (patch) | |
tree | 5934671c94ecbe759df3d8a48c388fe62188bd55 /crypto/pem | |
parent | b8a5adf3ec46f1ce0fb80130f8b7c6e0dcb5bd41 (diff) |
pem: fix a memory leak in PEM_write_bio_PrivateKey_traditional
The copy of PKEY should be released on the error path.
Easily reproduced with "ED448" context.
Signed-off-by: Milan Broz <gmazyland@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19536)
(cherry picked from commit 608aca8ed2becccfe9c238846834ea2b162fc98b)
Diffstat (limited to 'crypto/pem')
-rw-r--r-- | crypto/pem/pem_pkey.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/crypto/pem/pem_pkey.c b/crypto/pem/pem_pkey.c index f9346486dd..53367c03db 100644 --- a/crypto/pem/pem_pkey.c +++ b/crypto/pem/pem_pkey.c @@ -343,6 +343,7 @@ int PEM_write_bio_PrivateKey_traditional(BIO *bp, const EVP_PKEY *x, if (x->ameth == NULL || x->ameth->old_priv_encode == NULL) { ERR_raise(ERR_LIB_PEM, PEM_R_UNSUPPORTED_PUBLIC_KEY_TYPE); + EVP_PKEY_free(copy); return 0; } BIO_snprintf(pem_str, 80, "%s PRIVATE KEY", x->ameth->pem_str); |