Fix export of provided EC keys
authorRichard Levitte <levitte@openssl.org>
Mon, 23 Mar 2020 12:19:40 +0000 (13:19 +0100)
committerRichard Levitte <levitte@openssl.org>
Wed, 8 Apr 2020 13:30:25 +0000 (15:30 +0200)
The exporter freed a buffer too soon, and there were attempts to use
its data later, which was overwritten by something else at that
point.

Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/11358)

providers/implementations/keymgmt/ec_kmgmt.c

index 77d4753723d5e8625aed7543d62db736ff9e7e36..661aa2de9fc7f5824f7c98d38334b3da3ca33eeb 100644 (file)
@@ -352,13 +352,10 @@ int ec_export(void *keydata, int selection, OSSL_CALLBACK *param_cb,
     if ((selection & OSSL_KEYMGMT_SELECT_OTHER_PARAMETERS) != 0)
         ok = ok && otherparams_to_params(ec, tmpl, NULL);
 
-    if (!ok
-        || (params = OSSL_PARAM_BLD_to_param(tmpl)) == NULL)
-        goto err;
+    if (ok && (params = OSSL_PARAM_BLD_to_param(tmpl)) != NULL)
+        ok = param_cb(params, cbarg);
 
-    ok = param_cb(params, cbarg);
     OSSL_PARAM_BLD_free_params(params);
-err:
     OSSL_PARAM_BLD_free(tmpl);
     OPENSSL_free(pub_key);
     return ok;