From 866e9e15eae3156d1ef738db3e926d36de967f5b Mon Sep 17 00:00:00 2001 From: night1rider Date: Sat, 8 Aug 2026 16:47:56 -0600 Subject: [PATCH] asn.c: guard empty otherName copy to avoid NULL memcpy (UBSan) When a subjectAltName otherName has an empty value, SetDNSEntry() called XMEMCPY(dst, NULL, 0). Passing NULL to memcpy is undefined behavior and aborts under UBSan. Skip the copy unless there is real data to copy. --- wolfcrypt/src/asn.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wolfcrypt/src/asn.c b/wolfcrypt/src/asn.c index 8df1b2ea52..8e6c7560ee 100644 --- a/wolfcrypt/src/asn.c +++ b/wolfcrypt/src/asn.c @@ -14981,7 +14981,9 @@ static int SetDNSEntry(void* heap, DNS_entry* pool, word32* poolUsed, /* Set tag type, name length, name and NUL terminate name. */ dnsEntry->type = type; dnsEntry->len = strLen; - XMEMCPY(dnsEntry_name, str, (size_t)strLen); + if (str != NULL && strLen > 0) { + XMEMCPY(dnsEntry_name, str, (size_t)strLen); + } dnsEntry_name[strLen] = '\0'; #ifdef WOLFSSL_RID_ALT_NAME