From: valdaarhun Date: Mon, 25 Jul 2022 13:19:19 +0000 (+0530) Subject: Fixes segfault occurrence in PEM_write() X-Git-Tag: OpenSSL_1_1_1r~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3b9082c844913d3a0efada9fac0bd2924ce1a8f2;p=thirdparty%2Fopenssl.git Fixes segfault occurrence in PEM_write() Checks if header is NULL or not before calling strlen(). CLA: trivial Fixes #18825 Reviewed-by: Tomas Mraz Reviewed-by: Ben Kaduk Reviewed-by: Paul Dale (Merged from https://github.com/openssl/openssl/pull/18865) (cherry picked from commit 205957405d08ef199e6ab654e333a627bbca9ccc) --- diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c index 2de093595d0..c2cf407931d 100644 --- a/crypto/pem/pem_lib.c +++ b/crypto/pem/pem_lib.c @@ -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;