Skip to content

Commit 7be16bc

Browse files
committed
fix(mdns): fix mdns answer append while host is invalid
1 parent b5be844 commit 7be16bc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

components/mdns/mdns.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,6 +1350,20 @@ static uint8_t _mdns_append_service_ptr_answers(uint8_t *packet, uint16_t *index
13501350
*/
13511351
static uint8_t _mdns_append_answer(uint8_t *packet, uint16_t *index, mdns_out_answer_t *answer, mdns_if_t tcpip_if)
13521352
{
1353+
if (answer->host) {
1354+
bool is_host_valid = (&_mdns_self_host == answer->host);
1355+
mdns_host_item_t *target_host = _mdns_host_list;
1356+
while (target_host && !is_host_valid) {
1357+
if (target_host == answer->host) {
1358+
is_host_valid = true;
1359+
}
1360+
target_host = target_host->next;
1361+
}
1362+
if (!is_host_valid) {
1363+
return 0;
1364+
}
1365+
}
1366+
13531367
if (answer->type == MDNS_TYPE_PTR) {
13541368
if (answer->service) {
13551369
return _mdns_append_service_ptr_answers(packet, index, answer->service, answer->flush, answer->bye);

0 commit comments

Comments
 (0)