From 228cc557fe4ca29e34eccb3a1846d7f754879aed 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. --- 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 f7b51df147..941e60a318 100644 --- a/lib/dns/rdataslab.c +++ b/lib/dns/rdataslab.c @@ -361,7 +361,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; }