From: xkernel Date: Wed, 14 Dec 2022 16:22:40 +0000 (+0800) Subject: ec_kmgmt.c: check the return of BN_CTX_get() in time. X-Git-Tag: openssl-3.2.0-alpha1~1561 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=467b0492c1e597857b30b91ed72605387aa9825b;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/19905) --- diff --git a/providers/implementations/keymgmt/ec_kmgmt.c b/providers/implementations/keymgmt/ec_kmgmt.c index b23fab5fde2..cecb8cef3ee 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;