fix(mdns): Fix memory issues reported by valgrind

* Read after the allocated area (which may lead to subsequent
mdns name corruption)
* Potentially uninit variable used in condition
This commit is contained in:
David Cermak
2023-03-19 20:58:06 +01:00
parent 574738b8d3
commit 0a682e7f12

View File

@ -678,7 +678,7 @@ static uint16_t append_fqdn_dots(uint8_t *packet, uint16_t *index, const char *n
char *end = host;
char *start = host;
do {
end = memchr(start, '.', len);
end = memchr(start, '.', host + len - start);
end = end ? end : host + len;
int part_len = end - start;
if (!append_single_str(packet, index, start, part_len)) {
@ -733,6 +733,7 @@ search_next:
//read the destination into name and compare
name.parts = 0;
name.sub = 0;
name.invalid = false;
name.host[0] = 0;
name.service[0] = 0;
name.proto[0] = 0;