]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix memleak in PKCS12_pbe_crypt_ex()
authorRoberto Hueso Gomez <roberto@robertohueso.org>
Fri, 15 Jul 2022 09:21:30 +0000 (11:21 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 18 Jul 2022 08:19:11 +0000 (10:19 +0200)
Makes sure that the variable 'out' is free on every error path.

Fixes #18689

Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18808)

crypto/pkcs12/p12_decr.c

index 87232e773794ee209a870adb7ecf72d2e307048d..c4c63a2701a70e0a3fd54773082e4c4746189573 100644 (file)
@@ -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;
             }