]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test/evp_extra_test.c: Add check for BIO_new()
authorJiasheng Jiang <jiashengjiangcool@gmail.com>
Tue, 8 Jul 2025 22:39:31 +0000 (22:39 +0000)
committerNeil Horman <nhorman@openssl.org>
Sun, 28 Dec 2025 21:52:18 +0000 (16:52 -0500)
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 <jiashengjiangcool@gmail.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Neil Horman <nhorman@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27994)

test/evp_extra_test.c

index 9c94dc1b64175ce6c5622643a54ee627b4ac9b3b..cc25ad585373d3adaca75f2201a8cd8dc26b825b 100644 (file)
@@ -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))