From: Pauli Date: Thu, 8 Oct 2020 23:32:04 +0000 (+1000) Subject: coverity 1414446 out-of-bounds access: allocate \0 terminator byte to be safe X-Git-Tag: openssl-3.0.0-alpha7~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=fb33f99409972ea3d217399558d3baed4a57926d;p=thirdparty%2Fopenssl.git 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) --- diff --git a/test/v3nametest.c b/test/v3nametest.c index 9b81988ddd4..df12c15f095 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),