From 24f55ce9b488a02b7e7efe962f99037dc07410a5 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Fri, 10 Jan 2025 11:41:02 +0100 Subject: [PATCH] fix(mdns): Fixed potential out-of-bound interface error invalid mdns_if was handled for enabling/announcing pcbs, but not for the consequent browsing Closes coverity isssue: 470162 Out-of-bounds access --- components/mdns/mdns.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 2cda7b2291..c1d41de0e8 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -4479,10 +4479,11 @@ void mdns_preset_if_handle_system_event(void *arg, esp_event_base_t event_base, case IP_EVENT_GOT_IP6: { ip_event_got_ip6_t *event = (ip_event_got_ip6_t *) event_data; mdns_if_t mdns_if = _mdns_get_if_from_esp_netif(event->esp_netif); - if (mdns_if < MDNS_MAX_INTERFACES) { - post_mdns_enable_pcb(mdns_if, MDNS_IP_PROTOCOL_V6); - post_mdns_announce_pcb(mdns_if, MDNS_IP_PROTOCOL_V4); + if (mdns_if >= MDNS_MAX_INTERFACES) { + return; } + post_mdns_enable_pcb(mdns_if, MDNS_IP_PROTOCOL_V6); + post_mdns_announce_pcb(mdns_if, MDNS_IP_PROTOCOL_V4); mdns_browse_t *browse = _mdns_server->browse; while (browse) { _mdns_browse_send(browse, mdns_if);