]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix potential NULL pointer dereference
authorJuergen Christ <jchrist@linux.ibm.com>
Mon, 16 Jan 2023 10:37:15 +0000 (11:37 +0100)
committerTomas Mraz <tomas@openssl.org>
Tue, 17 Jan 2023 16:37:55 +0000 (17:37 +0100)
In EC key generation, if allocation of struct ec_gen_ctx fails, values
provided by parameters are copied into the context at represented by a NULL
pointer.  To fix this, prevent copy if allocation fails.

Signed-off-by: Juergen Christ <jchrist@linux.ibm.com>
Reviewed-by: Paul Dale <pauli@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/20055)

providers/implementations/keymgmt/ec_kmgmt.c

index cecb8cef3eebe620ead1296d5e79061bbb5400e0..990d03794add919348d43ac7ecd873b39ebe88fa 100644 (file)
@@ -1006,10 +1006,10 @@ static void *ec_gen_init(void *provctx, int selection,
         gctx->libctx = libctx;
         gctx->selection = selection;
         gctx->ecdh_mode = 0;
-    }
-    if (!ec_gen_set_params(gctx, params)) {
-        OPENSSL_free(gctx);
-        gctx = NULL;
+        if (!ec_gen_set_params(gctx, params)) {
+            OPENSSL_free(gctx);
+            gctx = NULL;
+        }
     }
     return gctx;
 }