From: Tomas Mraz Date: Mon, 11 Oct 2021 13:03:47 +0000 (+0200) Subject: ctrl_params_translate: Fix leak of BN_CTX X-Git-Tag: openssl-3.2.0-alpha1~3473 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=922422119df1f6aabd2a15e6e4108d98b6143adf;p=thirdparty%2Fopenssl.git ctrl_params_translate: Fix leak of BN_CTX Also add a missing allocation failure check. Fixes #16788 Reviewed-by: Matt Caswell Reviewed-by: Bernd Edlinger (Merged from https://github.com/openssl/openssl/pull/16804) --- diff --git a/crypto/evp/ctrl_params_translate.c b/crypto/evp/ctrl_params_translate.c index 88945e13e62..b17ce3cbf9b 100644 --- a/crypto/evp/ctrl_params_translate.c +++ b/crypto/evp/ctrl_params_translate.c @@ -1595,10 +1595,13 @@ static int get_payload_public_key(enum state state, const EC_GROUP *ecg = EC_KEY_get0_group(eckey); const EC_POINT *point = EC_KEY_get0_public_key(eckey); + if (bnctx == NULL) + return 0; ctx->sz = EC_POINT_point2buf(ecg, point, POINT_CONVERSION_COMPRESSED, &buf, bnctx); ctx->p2 = buf; + BN_CTX_free(bnctx); break; } return 0;