From: Matt Caswell Date: Thu, 29 Sep 2022 11:08:49 +0000 (+0100) Subject: Ensure we call the cleanup() function when cleaning an EVP_CIPHER_CTX X-Git-Tag: openssl-3.2.0-alpha1~1978 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f817a7439eaa705429cf699dd0485e665b0ffc49;p=thirdparty%2Fopenssl.git Ensure we call the cleanup() function when cleaning an EVP_CIPHER_CTX In some circumstances we were not calling the cleanup() function to remove cipher specific data from an EVP_CIPHER_CTX. Reviewed-by: Tomas Mraz Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/19300) --- diff --git a/crypto/evp/evp_enc.c b/crypto/evp/evp_enc.c index c1f5d2ca540..77dc815dd94 100644 --- a/crypto/evp/evp_enc.c +++ b/crypto/evp/evp_enc.c @@ -159,6 +159,8 @@ static int evp_cipher_init_internal(EVP_CIPHER_CTX *ctx, * (legacy code) */ if (cipher != NULL && ctx->cipher != NULL) { + if (ctx->cipher->cleanup != NULL && !ctx->cipher->cleanup(ctx)) + return 0; OPENSSL_clear_free(ctx->cipher_data, ctx->cipher->ctx_size); ctx->cipher_data = NULL; }