Skip to content

Commit

Permalink
Merge pull request #526 from zwx1995esp/fix/mdns_send_answer_while_ho…
Browse files Browse the repository at this point in the history
…st_is_invalid

fix(mdns): fix mdns answer append while host is invalid
  • Loading branch information
gabsuren authored Mar 12, 2024
2 parents b5be844 + 7be16bc commit 46a6244
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions components/mdns/mdns.c
Original file line number Diff line number Diff line change
Expand Up @@ -1350,6 +1350,20 @@ static uint8_t _mdns_append_service_ptr_answers(uint8_t *packet, uint16_t *index
*/
static uint8_t _mdns_append_answer(uint8_t *packet, uint16_t *index, mdns_out_answer_t *answer, mdns_if_t tcpip_if)
{
if (answer->host) {
bool is_host_valid = (&_mdns_self_host == answer->host);
mdns_host_item_t *target_host = _mdns_host_list;
while (target_host && !is_host_valid) {
if (target_host == answer->host) {
is_host_valid = true;
}
target_host = target_host->next;
}
if (!is_host_valid) {
return 0;
}
}

if (answer->type == MDNS_TYPE_PTR) {
if (answer->service) {
return _mdns_append_service_ptr_answers(packet, index, answer->service, answer->flush, answer->bye);
Expand Down

0 comments on commit 46a6244

Please sign in to comment.