From 7be16bcc88f3f12ec5e6293feda1182302ba195a Mon Sep 17 00:00:00 2001 From: zwx Date: Mon, 11 Mar 2024 20:26:38 +0800 Subject: [PATCH] fix(mdns): fix mdns answer append while host is invalid --- components/mdns/mdns.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index cfeb6f5ab..ca208664c 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -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);