Skip to content

Commit 75a8e86

Browse files
committed
fix(mdns): Fixed potential overflow when allocating txt data
Closes coverity warning: 470092 Overflowed integer argument
1 parent 907087c commit 75a8e86

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

components/mdns/mdns.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3486,8 +3486,9 @@ static void _mdns_result_txt_create(const uint8_t *data, size_t len, mdns_txt_it
34863486
uint16_t i = 0, y;
34873487
size_t partLen = 0;
34883488
int num_items = _mdns_txt_items_count_get(data, len);
3489-
if (num_items < 0) {
3490-
return;//error
3489+
if (num_items < 0 || num_items > SIZE_MAX / sizeof(mdns_txt_item_t)) {
3490+
// Error: num_items is incorrect (or too large to allocate)
3491+
return;
34913492
}
34923493

34933494
if (!num_items) {

0 commit comments

Comments
 (0)