mdns: Fix issue with some mDNS parsers

Some mDNS parser have issue with zero terminated TXT lists. This fix targets to overcome this issue. Found and tested with jmdns.
This commit is contained in:
me-no-dev 2018-01-17 19:06:42 +02:00
parent 2016478676
commit 51dde19a76

View File

@ -803,7 +803,7 @@ static uint16_t _mdns_append_txt_record(uint8_t * packet, uint16_t * index, mdns
record_length += part_length;
uint16_t data_len_location = *index - 2;
uint16_t data_len = 1;
uint16_t data_len = 0;
char * tmp;
mdns_txt_linked_item_t * txt = service->txt;
@ -820,9 +820,11 @@ static uint16_t _mdns_append_txt_record(uint8_t * packet, uint16_t * index, mdns
}
txt = txt->next;
}
if (!data_len) {
data_len = 1;
packet[*index] = 0;
*index = *index + 1;
}
_mdns_set_u16(packet, data_len_location, data_len);
record_length += data_len;
return record_length;