From 0e3218dcd0e7305b04e13135b1a54ccb6f8f0928 Mon Sep 17 00:00:00 2001 From: Luiz Angelo Daros de Luca Date: Fri, 15 Oct 2021 20:19:05 -0300 Subject: [PATCH] ASN: zero-terminate name constraints strings Signed-off-by: Luiz Angelo Daros de Luca --- wolfcrypt/src/asn.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 666c011e6..07d55c192 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -15272,7 +15272,7 @@ static int DecodeSubtree(const byte* input, int sz, Base_entry** head, return MEMORY_E; } - entry->name = (char*)XMALLOC(strLength, heap, DYNAMIC_TYPE_ALTNAME); + entry->name = (char*)XMALLOC(strLength+1, heap, DYNAMIC_TYPE_ALTNAME); if (entry->name == NULL) { WOLFSSL_MSG("allocate error"); XFREE(entry, heap, DYNAMIC_TYPE_ALTNAME); @@ -15280,6 +15280,7 @@ static int DecodeSubtree(const byte* input, int sz, Base_entry** head, } XMEMCPY(entry->name, &input[nameIdx], strLength); + entry->name[strLength] = '\0'; entry->nameSz = strLength; entry->type = bType;