Ensure NULL terminator is not written past end of allocated buffer.

This commit is contained in:
Darell Tan 2017-11-13 23:57:18 +08:00
parent db4e276662
commit 9f70ccd676

4
mdns.c
View File

@ -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;