From 3fadd9efec6d0d5b447f26142eef1b2fd9c1bb25 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Wed, 13 Mar 2024 10:15:03 +1100 Subject: [PATCH] Only call memmove if the rdata length is non zero This avoids undefined behaviour on zero length rdata where the data pointer is NULL. (cherry picked from commit 228cc557fe4ca29e34eccb3a1846d7f754879aed) --- lib/dns/rdataslab.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/dns/rdataslab.c b/lib/dns/rdataslab.c index 24fdaa83a1..2b4cc4bed3 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -320,7 +320,9 @@ dns_rdataslab_fromrdataset(dns_rdataset_t *rdataset, isc_mem_t *mctx, ? DNS_RDATASLAB_OFFLINE : 0; } - memmove(rawbuf, x[i].rdata.data, x[i].rdata.length); + if (x[i].rdata.length != 0) { + memmove(rawbuf, x[i].rdata.data, x[i].rdata.length); + } rawbuf += x[i].rdata.length; }