summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorxkernel <xkernel.wang@foxmail.com>2022-12-15 00:22:40 +0800
committerTomas Mraz <tomas@openssl.org>2022-12-22 12:16:48 +0100
commit63549494c8912aecbb382b7250179b2265b9bd83 (patch)
treec27a17b75693b7d1046cd4ff8aac40f2eb274bfc
parent9f78288f15b27cfc7de558f6bc0fbd8d6c1eaef9 (diff)
ec_kmgmt.c: check the return of BN_CTX_get() in time.
If x and y are all NULL, then it is unnecessary to do subsequent operations. Reviewed-by: Shane Lontis <shane.lontis@oracle.com> Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/19905) (cherry picked from commit 467b0492c1e597857b30b91ed72605387aa9825b)
-rw-r--r--providers/implementations/keymgmt/ec_kmgmt.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c
index 2763b4f3a1..30c8a30105 100644
--- a/providers/implementations/keymgmt/ec_kmgmt.c
+++ b/providers/implementations/keymgmt/ec_kmgmt.c
@@ -158,10 +158,16 @@ int key_to_params(const EC_KEY *eckey, OSSL_PARAM_BLD *tmpl,
goto err;
}
if (px != NULL || py != NULL) {
- if (px != NULL)
+ if (px != NULL) {
x = BN_CTX_get(bnctx);
- if (py != NULL)
+ if (x == NULL)
+ goto err;
+ }
+ if (py != NULL) {
y = BN_CTX_get(bnctx);
+ if (y == NULL)
+ goto err;
+ }
if (!EC_POINT_get_affine_coordinates(ecg, pub_point, x, y, bnctx))
goto err;