summaryrefslogtreecommitdiffstats
path: root/crypto/pem
diff options
context:
space:
mode:
authorvaldaarhun <icegambit91@gmail.com>2022-07-25 18:49:19 +0530
committerPauli <pauli@openssl.org>2022-07-29 12:39:22 +1000
commit683480726f6ab46216e30c7505d1a3c4ec90ace9 (patch)
treea55c4055aee44009ad8c32204fe0ada6e2a70686 /crypto/pem
parenta1598fb98e93fdf947327561071341012acc5c99 (diff)
Fixes segfault occurrence in PEM_write()
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)
Diffstat (limited to 'crypto/pem')
-rw-r--r--crypto/pem/pem_lib.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/crypto/pem/pem_lib.c b/crypto/pem/pem_lib.c
index 5097507019..fa24831fe3 100644
--- a/crypto/pem/pem_lib.c
+++ b/crypto/pem/pem_lib.c
@@ -627,7 +627,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;