kdf: avoid NULL dereference on malloc failure in sshkdf
authorPauli <pauli@openssl.org>
Thu, 31 Mar 2022 21:06:17 +0000 (08:06 +1100)
committerPauli <pauli@openssl.org>
Sun, 10 Apr 2022 23:53:34 +0000 (09:53 +1000)
Fixes #18009

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/18011)

providers/implementations/kdfs/sshkdf.c

index 6c1cf7e615df0ba3fc89d3c05e89ed93511480ff..a8b23a705cfa8a3d2af58a071cd5af4379e699b5 100644 (file)
@@ -60,7 +60,8 @@ static void *kdf_sshkdf_new(void *provctx)
 
     if ((ctx = OPENSSL_zalloc(sizeof(*ctx))) == NULL)
         ERR_raise(ERR_LIB_PROV, ERR_R_MALLOC_FAILURE);
-    ctx->provctx = provctx;
+    else
+        ctx->provctx = provctx;
     return ctx;
 }