From: Jiasheng Jiang Date: Mon, 21 Feb 2022 02:10:23 +0000 (+0800) Subject: fuzz/fuzz_rand.c: Add check for OSSL_LIB_CTX_new X-Git-Tag: openssl-3.2.0-alpha1~2905 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=885d97fbf84fb9de7548a5f6d4e90798f719022a;p=thirdparty%2Fopenssl.git fuzz/fuzz_rand.c: Add check for OSSL_LIB_CTX_new As the potential failure of the OPENSSL_zalloc(), the OSSL_LIB_CTX_new() could return NULL. Therefore, it should be better to check it and return error if fails in order to guarantee the success of the initialization. Signed-off-by: Jiasheng Jiang Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/17738) --- diff --git a/fuzz/fuzz_rand.c b/fuzz/fuzz_rand.c index 5bd343d8ae9..d71dfd7a3c6 100644 --- a/fuzz/fuzz_rand.c +++ b/fuzz/fuzz_rand.c @@ -146,6 +146,8 @@ static int fuzz_rand_provider_init(const OSSL_CORE_HANDLE *handle, const OSSL_DISPATCH **out, void **provctx) { *provctx = OSSL_LIB_CTX_new(); + if (*provctx == NULL) + return 0; *out = fuzz_rand_method; return 1; }