From 2eb458118c3de09cea42749098df1f93dc0e9eca Mon Sep 17 00:00:00 2001 From: Joseph Sutton Date: Mon, 1 May 2023 11:22:02 +1200 Subject: [PATCH] =?UTF-8?q?lib:addns:=20Don=E2=80=99t=20call=20memcpy()=20?= =?UTF-8?q?with=20a=20NULL=20pointer?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Doing so is undefined behaviour. Signed-off-by: Joseph Sutton Reviewed-by: Andrew Bartlett --- lib/addns/dnsmarshall.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/addns/dnsmarshall.c b/lib/addns/dnsmarshall.c index 6c93b98144f..c95420304f0 100644 --- a/lib/addns/dnsmarshall.c +++ b/lib/addns/dnsmarshall.c @@ -88,7 +88,9 @@ void dns_marshall_buffer(struct dns_buffer *buf, const uint8_t *data, buf->data = new_data; } - memcpy(buf->data + buf->offset, data, len); + if (data != NULL) { + memcpy(buf->data + buf->offset, data, len); + } buf->offset += len; return; }