From: Jiasheng Jiang Date: Tue, 8 Jul 2025 22:39:31 +0000 (+0000) Subject: test/evp_extra_test.c: Add check for BIO_new() X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7ed1f08326e6f71c7be2e6cbff20cae0a32acdbd;p=thirdparty%2Fopenssl.git test/evp_extra_test.c: Add check for BIO_new() Add check for the return value of BIO_new() to avoid NULL pointer dereference. Fixes: fd19fc4c27 ("Test that a key is usable after an EVP_PKEY_fromdata call") Signed-off-by: Jiasheng Jiang Reviewed-by: Dmitry Belyavskiy Reviewed-by: Frederik Wedel-Heinen Reviewed-by: Neil Horman (Merged from https://github.com/openssl/openssl/pull/27994) --- diff --git a/test/evp_extra_test.c b/test/evp_extra_test.c index 9c94dc1b64..cc25ad5853 100644 --- a/test/evp_extra_test.c +++ b/test/evp_extra_test.c @@ -1185,6 +1185,9 @@ static int test_selection(EVP_PKEY *pkey, int selection) int ret; BIO *bio = BIO_new(BIO_s_mem()); + if (!TEST_ptr(bio)) + goto err; + ret = PEM_write_bio_PUBKEY(bio, pkey); if ((selection & OSSL_KEYMGMT_SELECT_PUBLIC_KEY) != 0) { if (!TEST_true(ret))