]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
apps/lib/log.c: Add check for BIO_new()
authorJiasheng Jiang <jiashengjiangcool@gmail.com>
Fri, 27 Jun 2025 18:13:41 +0000 (18:13 +0000)
committerTomas Mraz <tomas@openssl.org>
Mon, 1 Dec 2025 10:30:00 +0000 (11:30 +0100)
Add check for the return value of BIO_new() to avoid potential NULL pointer dereference.

Fixes: 8a2ec00d7f ("apps/lib/http_server.{c,h}: clean up logging and move it to log.{c,h}")
Signed-off-by: Jiasheng Jiang <jiashengjiangcool@gmail.com>
Reviewed-by: Frederik Wedel-Heinen <fwh.openssl@gmail.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27918)

apps/lib/log.c

index a5e2f5507afdf7d4e17a725e040645ce16299ab9..cfe5973960ec7eb58f387cdd48a6cfe4708626e2 100644 (file)
@@ -46,6 +46,9 @@ static void log_with_prefix(const char *prog, const char *fmt, va_list ap)
     char prefix[80];
     BIO *bio, *pre = BIO_new(BIO_f_prefix());
 
+    if (pre == NULL)
+        return;
+
     (void)BIO_snprintf(prefix, sizeof(prefix), "%s: ", prog);
     (void)BIO_set_prefix(pre, prefix);
     bio = BIO_push(pre, bio_err);