From e7dabb14f7c8fd9bd2bea55d8f1accc65323a1c0 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 7 Sep 2021 13:05:38 +0200 Subject: [PATCH 1/2] mdns: Fix potential null dereference identified by fuzzer tests --- components/mdns/mdns.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 417b01fe0f..7045c76bc7 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -2775,7 +2775,8 @@ static bool _mdns_question_matches(mdns_parsed_question_t * question, uint16_t t } } else if (service && (type == MDNS_TYPE_SRV || type == MDNS_TYPE_TXT)) { const char * name = _mdns_get_service_instance_name(service->service); - if (name && question->host && !strcasecmp(name, question->host) + if (name && question->host && question->service && question->proto && question->domain + && !strcasecmp(name, question->host) && !strcasecmp(service->service->service, question->service) && !strcasecmp(service->service->proto, question->proto) && !strcasecmp(MDNS_DEFAULT_DOMAIN, question->domain)) { @@ -3237,7 +3238,7 @@ void mdns_parse_packet(mdns_rx_packet_t * packet) } else if (service) { // only detect srv collision if service existed col = _mdns_check_srv_collision(service->service, priority, weight, port, name->host, name->domain); } - if (col && (parsed_packet->probe || parsed_packet->authoritative)) { + if (service && col && (parsed_packet->probe || parsed_packet->authoritative)) { if (col > 0 || !port) { do_not_reply = true; if (_mdns_server->interfaces[packet->tcpip_if].pcbs[packet->ip_protocol].probe_running) { From 2a2b95b9c22bc5090d87a4f4317288b64b14fcd9 Mon Sep 17 00:00:00 2001 From: David Cermak Date: Tue, 21 Sep 2021 11:06:59 +0200 Subject: [PATCH 2/2] mdns: Update copyright header --- components/mdns/mdns.c | 18 +++++------------- tools/ci/check_copyright_ignore.txt | 1 - 2 files changed, 5 insertions(+), 14 deletions(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 7045c76bc7..9f5a545542 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -1,16 +1,8 @@ -// Copyright 2015-2016 Espressif Systems (Shanghai) PTE LTD -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at - -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. +/* + * SPDX-FileCopyrightText: 2015-2021 Espressif Systems (Shanghai) CO LTD + * + * SPDX-License-Identifier: Apache-2.0 + */ #include "mdns.h" #include "mdns_private.h" diff --git a/tools/ci/check_copyright_ignore.txt b/tools/ci/check_copyright_ignore.txt index e907e8755c..fedac54bb7 100644 --- a/tools/ci/check_copyright_ignore.txt +++ b/tools/ci/check_copyright_ignore.txt @@ -1983,7 +1983,6 @@ components/mdns/host_test/components/freertos_linux/queue_unique_ptr.hpp components/mdns/host_test/main/main.c components/mdns/include/mdns.h components/mdns/include/mdns_console.h -components/mdns/mdns.c components/mdns/mdns_console.c components/mdns/mdns_networking_lwip.c components/mdns/mdns_networking_socket.c