Skip to content

Commit 8fd2c99

Browse files
committed
fix(mdns): Fix parsing incorrect txt records
Issue discovered when fuzzing packet parser, received packet with inconsistent txt section caused issues on final cleanup
1 parent 703c492 commit 8fd2c99

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

components/mdns/mdns.c

+3-2
Original file line numberDiff line numberDiff line change
@@ -3593,7 +3593,7 @@ static void _mdns_result_txt_create(const uint8_t *data, size_t len, mdns_txt_it
35933593
}
35943594

35953595
int name_len = _mdns_txt_item_name_get_len(data + i, partLen);
3596-
if (name_len < 0) {//invalid item (no name)
3596+
if (name_len < 0 || txt_num >= num_items) {//invalid item (no name or more items than expected)
35973597
i += partLen;
35983598
continue;
35993599
}
@@ -3602,7 +3602,6 @@ static void _mdns_result_txt_create(const uint8_t *data, size_t len, mdns_txt_it
36023602
HOOK_MALLOC_FAILED;
36033603
goto handle_error;//error
36043604
}
3605-
36063605
mdns_txt_item_t *t = &txt[txt_num];
36073606
uint8_t *value_len = &txt_value_len[txt_num];
36083607
txt_num++;
@@ -3624,6 +3623,8 @@ static void _mdns_result_txt_create(const uint8_t *data, size_t len, mdns_txt_it
36243623
*value_len = new_value_len;
36253624
i += new_value_len;
36263625
t->value = value;
3626+
} else {
3627+
t->value = NULL;
36273628
}
36283629
}
36293630

0 commit comments

Comments
 (0)