]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fixes segfault occurrence in PEM_write()
authorvaldaarhun <icegambit91@gmail.com>
Mon, 25 Jul 2022 13:19:19 +0000 (18:49 +0530)
committerPauli <pauli@openssl.org>
Fri, 29 Jul 2022 02:39:51 +0000 (12:39 +1000)
Checks if header is NULL or not before calling strlen().

CLA: trivial

Fixes #18825

Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Ben Kaduk <kaduk@mit.edu>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/18865)

(cherry picked from commit 205957405d08ef199e6ab654e333a627bbca9ccc)

crypto/pem/pem_lib.c

index 2de093595d0d2e45962a78adf23ece83ee188f1d..c2cf407931d21308baee3b743522b70a75228319 100644 (file)
@@ -621,7 +621,7 @@ int PEM_write_bio(BIO *bp, const char *name, const char *header,
         (BIO_write(bp, "-----\n", 6) != 6))
         goto err;
 
-    i = strlen(header);
+    i = header != NULL ? strlen(header) : 0;
     if (i > 0) {
         if ((BIO_write(bp, header, i) != i) || (BIO_write(bp, "\n", 1) != 1))
             goto err;