Merge pull request #257 from david-cermak/fix/mdns_valgrind

fix(mdns): Fix memory issues reported by valgrind
This commit is contained in:
david-cermak
2023-03-20 16:49:36 +01:00
committed by GitHub
11 changed files with 11 additions and 63 deletions

View File

@ -6,7 +6,7 @@ endif()
idf_build_get_property(target IDF_TARGET)
if(${target} STREQUAL "linux")
set(dependencies esp_event esp_netif_linux esp_timer_linux esp_system)
set(dependencies esp_netif_linux esp_timer_linux esp_system)
set(srcs "mdns.c" ${MDNS_NETWORKING})
else()
set(dependencies lwip console esp_netif)

View File

@ -678,7 +678,7 @@ static uint16_t append_fqdn_dots(uint8_t *packet, uint16_t *index, const char *n
char *end = host;
char *start = host;
do {
end = memchr(start, '.', len);
end = memchr(start, '.', host + len - start);
end = end ? end : host + len;
int part_len = end - start;
if (!append_single_str(packet, index, start, part_len)) {
@ -733,6 +733,7 @@ search_next:
//read the destination into name and compare
name.parts = 0;
name.sub = 0;
name.invalid = false;
name.host[0] = 0;
name.service[0] = 0;
name.proto[0] = 0;

View File

@ -5,3 +5,7 @@ set(EXTRA_COMPONENT_DIRS "../..")
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(COMPONENTS main esp_netif_linux)
project(mdns_host)
# Enable sanitizers for mdns implementation
idf_component_get_property(mdns mdns COMPONENT_LIB)
target_link_options(${mdns} INTERFACE -fsanitize=address -fsanitize=undefined)

View File

@ -1,2 +0,0 @@
idf_component_register(SRCS esp_event_mock.c
INCLUDE_DIRS include)

View File

@ -1,21 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#include "esp_err.h"
#include "esp_event.h"
const char *WIFI_EVENT = "WIFI_EVENT";
const char *IP_EVENT = "IP_EVENT";
esp_err_t esp_event_handler_register(const char *event_base, int32_t event_id, void *event_handler, void *event_handler_arg)
{
return ESP_OK;
}
esp_err_t esp_event_handler_unregister(const char *event_base, int32_t event_id, void *event_handler)
{
return ESP_OK;
}

View File

@ -1,15 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
#include "stdbool.h"
#include "esp_err.h"
#include "esp_event_base.h"
#include "bsd/string.h"
esp_err_t esp_event_handler_register(const char *event_base, int32_t event_id, void *event_handler, void *event_handler_arg);
esp_err_t esp_event_handler_unregister(const char *event_base, int32_t event_id, void *event_handler);

View File

@ -1,19 +0,0 @@
/*
* SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
*
* SPDX-License-Identifier: Apache-2.0
*/
#pragma once
typedef enum {
WIFI_EVENT_STA_CONNECTED, /**< ESP32 station connected to AP */
WIFI_EVENT_STA_DISCONNECTED, /**< ESP32 station disconnected from AP */
WIFI_EVENT_AP_START, /**< ESP32 soft-AP start */
WIFI_EVENT_AP_STOP, /**< ESP32 soft-AP stop */
} mdns_used_event_t;
#define ESP_EVENT_DECLARE_BASE(x)
#define ESP_EVENT_ANY_ID (-1)
typedef void *esp_event_base_t;
typedef void *system_event_t;

View File

@ -1,3 +1,2 @@
idf_component_register(SRCS esp_netif_linux.c
INCLUDE_DIRS include $ENV{IDF_PATH}/components/esp_netif/include
REQUIRES esp_event)
INCLUDE_DIRS include $ENV{IDF_PATH}/components/esp_netif/include)

View File

@ -55,6 +55,7 @@ esp_err_t esp_netif_get_ip_info(esp_netif_t *esp_netif, esp_netif_ip_info_t *ip_
}
tmp = tmp->ifa_next;
}
freeifaddrs(addrs);
return ESP_OK;
}

View File

@ -1,6 +1,5 @@
idf_component_register(SRCS esp_timer_linux.c timer_task.cpp
INCLUDE_DIRS include
REQUIRES esp_event)
INCLUDE_DIRS include)
set_target_properties(${COMPONENT_LIB} PROPERTIES
CXX_STANDARD 17

View File

@ -7,6 +7,7 @@
#include <stdbool.h>
#include <stdint.h>
#include "bsd/string.h"
typedef struct esp_timer *esp_timer_handle_t;