From 9f70ccd6764dfb262e2caf9d30d3415c4f074982 Mon Sep 17 00:00:00 2001 From: Darell Tan Date: Mon, 13 Nov 2017 23:57:18 +0800 Subject: [PATCH] Ensure NULL terminator is not written past end of allocated buffer. --- mdns.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/mdns.c b/mdns.c index 4781f1d..abe8182 100644 --- a/mdns.c +++ b/mdns.c @@ -112,6 +112,10 @@ char *nlabel_to_str(const uint8_t *name) { p += label_len; } + // avoid writing NULL past end of buffer + if (buf_len == 0) + labelp--; + *labelp = '\0'; return label;