Merge branch 'bugfix/mdns_txt_length_collision_v4.0' into 'release/v4.0'

mDNS: Fix of text length calculation when detecting a collision(Backport v4.0)

See merge request espressif/esp-idf!12027
This commit is contained in:
David Čermák 2021-01-19 22:16:08 +08:00
commit b1178d092e

View File

@ -2094,7 +2094,7 @@ static int _mdns_check_srv_collision(mdns_service_t * service, uint16_t priority
*/ */
static int _mdns_check_txt_collision(mdns_service_t * service, const uint8_t * data, size_t len) static int _mdns_check_txt_collision(mdns_service_t * service, const uint8_t * data, size_t len)
{ {
size_t data_len = 1; size_t data_len = 0;
if (len == 1 && service->txt) { if (len == 1 && service->txt) {
return -1;//we win return -1;//we win
} else if (len > 1 && !service->txt) { } else if (len > 1 && !service->txt) {
@ -2105,7 +2105,7 @@ static int _mdns_check_txt_collision(mdns_service_t * service, const uint8_t * d
mdns_txt_linked_item_t * txt = service->txt; mdns_txt_linked_item_t * txt = service->txt;
while (txt) { while (txt) {
data_len += 2 + strlen(service->txt->key) + strlen(service->txt->value); data_len += 2 + strlen(txt->key) + strlen(txt->value);
txt = txt->next; txt = txt->next;
} }