Skip to content

About

Patched version of Espressif's mdns component from esp-protocols, compatible with ESP-IDF v4 builds of the Arduino platform.

Resources

Stars

0 stars

Watchers

0 watching

Forks

 
 

Latest commit

 

History

35 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

esp-mdns-fix

Link-time replacement for the precompiled ESP-IDF mDNS component (libmdns.a) shipped with the Tasmota Arduino-ESP32 2.0.18 / ESP-IDF 4.4.8 platform used by WLED's ESP32 V4 builds.

Why

The framework's mDNS responder has a NULL pointer dereference in _mdns_remove_scheduled_answer() that can be triggered remotely by ordinary mDNS traffic, rebooting the device (wled/WLED#6005). The fix exists upstream in esp-protocols but was never backported to IDF 4.4, and the platform is no longer maintained.

How it works

This library is built with libArchive: false, so its object files are passed directly to the linker. They define every global symbol exported by the framework's libmdns.a (mdns.c.obj, mdns_networking_lwip.c.obj, mdns_console.c.obj), so no member of that archive is ever pulled in. If one were, the duplicate definitions would cause a link error rather than a silent mix of two implementations.

The public headers (include/) are identical to the framework's, so the ABI seen by ESPmDNS, ArduinoOTA and precompiled consumers (e.g. libwifi_provisioning.a) is unchanged. No caller changes are needed.

The library is picked up by PlatformIO's LDF through ESPmDNS.h's #include "mdns.h".

Provenance

Base: components/mdns from espressif/esp-idf @ 8ba0dc0bc3 (the commit named in the framework's tools/sdk/versions.txt). That tree is a mirror of espressif/esp-protocols @ c73c797 (2022-11-07, between mdns-v1.0.7 and v1.0.8); all files match modulo whitespace. Headers match the framework's shipped include/mdns/include/*.h byte-for-byte (modulo line endings).

Configuration comes from the framework's precompiled sdkconfig.h, as for the original build.

Changes

Every change on top of the base is a separate commit; see git log 385504d.. for the full list. Fixes taken from upstream name the espressif/esp-protocols commit they came from: cherry-picks keep the upstream author (with a note where a hunk was adapted or dropped), rewritten ports say "Backport of" (git log --grep=espressif/esp-protocols 385504d..). The rest are local fixes for bugs still present upstream.

Notable fixes for remotely triggerable crashes:

  • NULL q->answers dereference in _mdns_remove_scheduled_answer() (wled/WLED#6005; upstream 4fa3023).
  • Unbounded recursion in name decompression, overflowing the mDNS task stack (GHSA-7fpr-vjw5-2c86; upstream 95c882c).
  • Out-of-bounds accesses on malformed compression pointers, A/AAAA records and TXT records.

Fixes were selected from the upstream history after c73c797 for memory safety and correctness of the receive path, queries, and the init/deinit cycle (mdns_free() → mdns_init(), which e.g. WLED performs on every reconnect via MDNS.end() / MDNS.begin()). Not applied:

  • Fixes to code that does not exist in this version (e.g. browse, subtype bye, txt copy helpers). This includes 25b3d5f, which fixes a removal loop introduced by the 8a69050 refactor; the 4.4 ACTION_SERVICE_DEL handler already removes only the one matching entry.
  • The larger API-race refactors (8a69050, 21c84bf) and the commits that depend on them, including 169405b for mdns_service_remove_all(). These change how every public API call reaches the service task. The failure modes of the mdns_free() path are covered by local fixes instead.

Known limitation, shared with upstream: public API calls hand their work to the service task through a fixed-size action queue without waiting, so they fail with ESP_ERR_NO_MEM while the queue is full (e.g. during an mDNS flood). Callers should check the result and retry.

Later upstream releases (mdns >= 1.0.8) require ESP-IDF >= 5.0 and change public struct layouts, so they cannot be used as drop-in replacements.

License

Apache-2.0, see LICENSE. Copyright Espressif Systems (Shanghai) CO LTD.

About

Patched version of Espressif's mdns component from esp-protocols, compatible with ESP-IDF v4 builds of the Arduino platform.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages