diff options
author | Shane Lontis <shane.lontis@oracle.com> | 2020-08-24 11:57:12 +1000 |
---|---|---|
committer | Shane Lontis <shane.lontis@oracle.com> | 2020-09-05 15:41:30 +1000 |
commit | 33200269110f0ed4a9c96be03b32cd8913f9e426 (patch) | |
tree | 2b9ba897f1fd0e6b97e269f69bb444dc183e3af9 /providers/implementations/keymgmt | |
parent | 0e540f231cbdc8e24e1496cf8ac265b62a983692 (diff) |
Fix coverity CID #1466371 - fix dereference before NULL check.
Reviewed-by: Matthias St. Pierre <Matthias.St.Pierre@ncp-e.com>
(Merged from https://github.com/openssl/openssl/pull/12708)
Diffstat (limited to 'providers/implementations/keymgmt')
-rw-r--r-- | providers/implementations/keymgmt/ec_kmgmt.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index 05b5fdd969..9c2e627e37 100644 --- a/providers/implementations/keymgmt/ec_kmgmt.c +++ b/providers/implementations/keymgmt/ec_kmgmt.c @@ -321,7 +321,7 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, void *cbarg) { EC_KEY *ec = keydata; - OSSL_PARAM_BLD *tmpl; + OSSL_PARAM_BLD *tmpl = NULL; OSSL_PARAM *params = NULL; unsigned char *pub_key = NULL, *genbuf = NULL; BN_CTX *bnctx = NULL; @@ -358,8 +358,11 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, if ((selection & OSSL_KEYMGMT_SELECT_DOMAIN_PARAMETERS) != 0) { bnctx = BN_CTX_new_ex(ec_key_get_libctx(ec)); + if (bnctx == NULL) { + ok = 0; + goto end; + } BN_CTX_start(bnctx); - ok = ok && (bnctx != NULL); ok = ok && ec_group_todata(EC_KEY_get0_group(ec), tmpl, NULL, ec_key_get_libctx(ec), ec_key_get0_propq(ec), bnctx, &genbuf); @@ -376,7 +379,7 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb, if (ok && (params = OSSL_PARAM_BLD_to_param(tmpl)) != NULL) ok = param_cb(params, cbarg); - +end: OSSL_PARAM_BLD_free_params(params); OSSL_PARAM_BLD_free(tmpl); OPENSSL_free(pub_key); |