]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
rand: add argument error checking to EVP_RAND_nonce()
authorPauli <ppzgs1@gmail.com>
Thu, 5 Jun 2025 03:28:37 +0000 (13:28 +1000)
committerTomas Mraz <tomas@openssl.org>
Mon, 9 Jun 2025 08:24:43 +0000 (10:24 +0200)
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27766)

(cherry picked from commit a2cd7ecd75dcd0de214319ec11bf5b3701bec7a3)

crypto/evp/evp_rand.c

index ac0c01f2ae1ec278332bff343ff66a24602065a0..37c519592f00b50c0f294d13d5b0869257b15ba1 100644 (file)
@@ -655,6 +655,11 @@ int EVP_RAND_nonce(EVP_RAND_CTX *ctx, unsigned char *out, size_t outlen)
 {
     int res;
 
+    if (ctx == NULL || out == NULL || outlen == 0) {
+        ERR_raise(ERR_LIB_EVP, ERR_R_PASSED_NULL_PARAMETER);
+        return 0;
+    }
+
     if (!evp_rand_lock(ctx))
         return 0;
     res = evp_rand_nonce_locked(ctx, out, outlen);