coverity 1414446 out-of-bounds access: allocate \0 terminator byte to be safe

Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org>
(Merged from https://github.com/openssl/openssl/pull/13091)
This commit is contained in:
Pauli 2020-10-09 09:32:04 +10:00
parent 19431e5e44
commit fb33f99409

View File

@ -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),