From 5d0c47303dd9ead0f2ad291dca1d4b7ce4e23b2b Mon Sep 17 00:00:00 2001 From: Jiacheng Guo Date: Fri, 3 Dec 2021 17:59:04 +0800 Subject: [PATCH] mdns: filter instance name for ANY queries The instance name in ANY quries was ignored. The MR fixes the issue. --- components/mdns/mdns.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 351b5c1695..f9fc8a0af4 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -1534,6 +1534,8 @@ static bool _mdns_service_match_ptr_question(const mdns_service_t *service, cons if (!_mdns_service_match(service, question->service, question->proto, NULL)) { return false; } + // The question parser stores anything before _type._proto in question->host + // So the question->host can be subtype or instance name based on its content if (question->sub) { mdns_subtype_t *subtype = service->subtype; while (subtype) { @@ -1544,6 +1546,11 @@ static bool _mdns_service_match_ptr_question(const mdns_service_t *service, cons } return false; } + if (question->host) { + if (strcasecmp(service->instance, question->host) != 0) { + return false; + } + } return true; }