]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
ec_kmgmt.c: check the return of BN_CTX_get() in time.
authorxkernel <xkernel.wang@foxmail.com>
Wed, 14 Dec 2022 16:22:40 +0000 (00:22 +0800)
committerTomas Mraz <tomas@openssl.org>
Thu, 22 Dec 2022 11:15:49 +0000 (12:15 +0100)
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)

providers/implementations/keymgmt/ec_kmgmt.c

index b23fab5fde2847b8a106c25d866d2f42ebe16390..cecb8cef3eebe620ead1296d5e79061bbb5400e0 100644 (file)
@@ -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;