From: Niels Dossche Date: Sun, 27 Oct 2024 20:48:17 +0000 (+0100) Subject: Fix potential memory leak in OSSL_HPKE_CTX_new() X-Git-Tag: openssl-3.5.0-alpha1~954 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8ff6edb9da6199b130bfb50bc27b2e58cc815932;p=thirdparty%2Fopenssl.git Fix potential memory leak in OSSL_HPKE_CTX_new() ctx->propq is a duplicated string, but the error code does not free the duplicated string's memory. If e.g. EVP_CIPHER_fetch() fails then we can leak the string's memory. Reviewed-by: Tom Cosgrove Reviewed-by: Kurt Roeckx Reviewed-by: Matt Caswell (Merged from https://github.com/openssl/openssl/pull/25812) --- diff --git a/crypto/hpke/hpke.c b/crypto/hpke/hpke.c index 5a403097c41..8dca5584cbc 100644 --- a/crypto/hpke/hpke.c +++ b/crypto/hpke/hpke.c @@ -841,6 +841,7 @@ OSSL_HPKE_CTX *OSSL_HPKE_CTX_new(int mode, OSSL_HPKE_SUITE suite, int role, err: EVP_CIPHER_free(ctx->aead_ciph); + OPENSSL_free(ctx->propq); OPENSSL_free(ctx); return NULL; }