From: Shane Lontis Date: Mon, 21 Sep 2020 01:39:04 +0000 (+1000) Subject: Fix CID 1466710 : Resource leak in ec_kmgmt due to new call to ossl_prov_is_running() X-Git-Tag: openssl-3.0.0-alpha7~147 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ced5231b04679dc31ce981d66d08260037fa40d8;p=thirdparty%2Fopenssl.git Fix CID 1466710 : Resource leak in ec_kmgmt due to new call to ossl_prov_is_running() Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/12930) --- diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index 63c51af3a19..2a8980ddf52 100644 --- a/providers/implementations/keymgmt/ec_kmgmt.c +++ b/providers/implementations/keymgmt/ec_kmgmt.c @@ -788,9 +788,13 @@ int ec_validate(void *keydata, int selection) { EC_KEY *eck = keydata; int ok = 0; - BN_CTX *ctx = BN_CTX_new_ex(ec_key_get_libctx(eck)); + BN_CTX *ctx = NULL; + + if (!ossl_prov_is_running()) + return 0; - if (!ossl_prov_is_running() || ctx == NULL) + ctx = BN_CTX_new_ex(ec_key_get_libctx(eck)); + if (ctx == NULL) return 0; if ((selection & EC_POSSIBLE_SELECTIONS) != 0)