Skip to content

Commit

Permalink
fix(mdns): Fix memory issues reported by valgrind
Browse files Browse the repository at this point in the history
* Read after the allocated area (which may lead to subsequent
mdns name corruption)
* Potentially uninit variable used in condition
  • Loading branch information
david-cermak committed Mar 19, 2023
1 parent 574738b commit 0a682e7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down Expand Up @@ -733,6 +733,7 @@ static uint16_t _mdns_append_fqdn(uint8_t *packet, uint16_t *index, const char *
//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;
Expand Down

0 comments on commit 0a682e7

Please sign in to comment.