Don't report success from ec_export if OSSL_PARAM_BLD_to_param failed
authorMatt Caswell <matt@openssl.org>
Mon, 6 Jun 2022 09:32:49 +0000 (10:32 +0100)
committerMatt Caswell <matt@openssl.org>
Wed, 8 Jun 2022 14:43:44 +0000 (15:43 +0100)
If the call to OSSL_PARAM_BLD_to_param() failed then ec_export was
reporting success, even though it has never called the param_cb.

Found due to:
https://github.com/openssl/openssl/pull/18355#issuecomment-1145993650

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18483)

providers/implementations/keymgmt/ec_kmgmt.c

index e120760e5f97d1f9dc9d02897f6e48d3e66737af..6f8638a89812898131a002b5a6fef3dd83f6189b 100644 (file)
@@ -498,6 +498,8 @@ 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);
+    else
+        ok = 0;
 end:
     OSSL_PARAM_free(params);
     OSSL_PARAM_BLD_free(tmpl);