Skip to content

Commit d7c7caa

Browse files
syzzercron2
authored andcommitted
mbedtls: gracefully exit if certificate file is NULL
Instead of crashing because we feed a NULL pointer to strlen(), gracefully exit with an error message. While at it, improve the error message a bit. Change-Id: I0d592d9d0c7ead296869f933c206c5d55e6cbed1 Reported-By: Joshua Rogers <[email protected]> Found-by: ZeroPath (https://zeropath.com/) Signed-off-by: Steffan Karger <[email protected]> Acked-by: Gert Doering <[email protected]> Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1419 Message-Id: <[email protected]> URL: https://www.mail-archive.com/[email protected]/msg34864.html Signed-off-by: Gert Doering <[email protected]>
1 parent 4ff746a commit d7c7caa

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/openvpn/ssl_mbedtls.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -466,10 +466,14 @@ tls_ctx_load_cert_file(struct tls_root_ctx *ctx, const char *cert_file, bool cer
466466

467467
if (cert_inline)
468468
{
469+
if (!cert_file)
470+
{
471+
msg(M_FATAL, "Cannot load inline certificate: NULL");
472+
}
469473
if (!mbed_ok(mbedtls_x509_crt_parse(ctx->crt_chain, (const unsigned char *)cert_file,
470474
strlen(cert_file) + 1)))
471475
{
472-
msg(M_FATAL, "Cannot load inline certificate file");
476+
msg(M_FATAL, "Cannot load inline certificate");
473477
}
474478
}
475479
else

0 commit comments

Comments
 (0)