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.


* Original commit: espressif/esp-idf@51dde19a76
This commit is contained in:
me-no-dev
2018-01-17 19:06:42 +02:00
committed by suren-gabrielyan-espressif
parent ad8c92db52
commit ef924f1aa5

View File

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