From bd23c233a4e8a07c7737013e6f4ad75434633637 Mon Sep 17 00:00:00 2001 From: Andrew Chalmers Date: Fri, 24 Jan 2025 17:39:04 +1030 Subject: [PATCH] fix(mdns): Fix _mdns_append_fqdn excessive stack usage Move "mdns_name_t name" declaration inside loop to move it out of scope and reclain stack space before recursion call. --- components/mdns/mdns.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/mdns/mdns.c b/components/mdns/mdns.c index 903cc02b4..f5f12cc13 100644 --- a/components/mdns/mdns.c +++ b/components/mdns/mdns.c @@ -751,12 +751,12 @@ static uint16_t _mdns_append_fqdn(uint8_t *packet, uint16_t *index, const char * //empty string so terminate return _mdns_append_u8(packet, index, 0); } - mdns_name_t name; static char buf[MDNS_NAME_BUF_LEN]; uint8_t len = strlen(strings[0]); //try to find first the string length in the packet (if it exists) uint8_t *len_location = (uint8_t *)memchr(packet, (char)len, *index); while (len_location) { + mdns_name_t name; //check if the string after len_location is the string that we are looking for if (memcmp(len_location + 1, strings[0], len)) { //not continuing with our string search_next: