From fb33f99409972ea3d217399558d3baed4a57926d Mon Sep 17 00:00:00 2001 From: Pauli Date: Fri, 9 Oct 2020 09:32:04 +1000 Subject: [PATCH] coverity 1414446 out-of-bounds access: allocate \0 terminator byte to be safe Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/13091) --- test/v3nametest.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/v3nametest.c b/test/v3nametest.c index 9b81988ddd..df12c15f09 100644 --- a/test/v3nametest.c +++ b/test/v3nametest.c @@ -289,10 +289,10 @@ static int run_cert(X509 *crt, const char *nameincert, for (; *pname != NULL; ++pname) { int samename = strcasecmp(nameincert, *pname) == 0; size_t namelen = strlen(*pname); - char *name = OPENSSL_malloc(namelen); + char *name = OPENSSL_malloc(namelen + 1); int match, ret; - memcpy(name, *pname, namelen); + memcpy(name, *pname, namelen + 1); match = -1; if (!TEST_int_ge(ret = X509_check_host(crt, name, namelen, 0, NULL),