aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShane Lontis <shane.lontis@oracle.com>2020-09-21 11:29:30 +1000
committerShane Lontis <shane.lontis@oracle.com>2020-09-23 17:16:39 +1000
commit965d3f36c49e2d0144330271be7c330b572b43df (patch)
tree559995576cea85159de505c3c94c789e48f6bab5
parentad2dbfb543ac1ba9c074fccd75c06b1d5d491393 (diff)
downloadopenssl-965d3f36c49e2d0144330271be7c330b572b43df.zip
openssl-965d3f36c49e2d0144330271be7c330b572b43df.tar.gz
openssl-965d3f36c49e2d0144330271be7c330b572b43df.tar.bz2
Fix CID 1466712 : Resource leak in ec_kmgmt due to new callto ossl_prov_is_running()
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/12930)
-rw-r--r--providers/implementations/keymgmt/ec_kmgmt.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c
index 1e32db1..63c51af 100644
--- a/providers/implementations/keymgmt/ec_kmgmt.c
+++ b/providers/implementations/keymgmt/ec_kmgmt.c
@@ -276,12 +276,16 @@ static int ec_match(const void *keydata1, const void *keydata2, int selection)
const EC_KEY *ec2 = keydata2;
const EC_GROUP *group_a = EC_KEY_get0_group(ec1);
const EC_GROUP *group_b = EC_KEY_get0_group(ec2);
- BN_CTX *ctx = BN_CTX_new_ex(ec_key_get_libctx(ec1));
+ BN_CTX *ctx = NULL;
int ok = 1;
if (!ossl_prov_is_running())
return 0;
+ ctx = BN_CTX_new_ex(ec_key_get_libctx(ec1));
+ if (ctx == NULL)
+ return 0;
+
if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0)
ok = ok && group_a != NULL && group_b != NULL
&& EC_GROUP_cmp(group_a, group_b, ctx) == 0;