From: Roberto Hueso Gomez Date: Fri, 15 Jul 2022 09:21:30 +0000 (+0200) Subject: Fix memleak in PKCS12_pbe_crypt_ex() X-Git-Tag: openssl-3.2.0-alpha1~2368 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=af801ec89205aaf6ebf8522d510d0b1fc29e3233;p=thirdparty%2Fopenssl.git Fix memleak in PKCS12_pbe_crypt_ex() Makes sure that the variable 'out' is free on every error path. Fixes #18689 Reviewed-by: Dmitry Belyavskiy Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/18808) --- diff --git a/crypto/pkcs12/p12_decr.c b/crypto/pkcs12/p12_decr.c index 87232e77379..c4c63a2701a 100644 --- a/crypto/pkcs12/p12_decr.c +++ b/crypto/pkcs12/p12_decr.c @@ -94,6 +94,8 @@ unsigned char *PKCS12_pbe_crypt_ex(const X509_ALGOR *algor, if (EVP_CIPHER_CTX_is_encrypting(ctx)) { if (EVP_CIPHER_CTX_ctrl(ctx, EVP_CTRL_AEAD_GET_TAG, (int)mac_len, out+outlen) < 0) { + OPENSSL_free(out); + out = NULL; ERR_raise(ERR_LIB_PKCS12, ERR_R_INTERNAL_ERROR); goto err; }