Commit Graph

43 Commits

Author SHA1 Message Date
144d4ad1d4 mdns: fix ignoring mdns packet with some invalid name entries in question field
In case of invalid name entry, only this entry is invalidated and parsing continues as other query entries could contain questions to be responded to


* Original commit: espressif/esp-idf@4bd4c7caf3
2022-05-27 17:44:23 +04:00
680bad646f add esp_eth component
* Original commit: espressif/esp-idf@90c4827bd2
2022-05-27 17:44:23 +04:00
4912bef740 mdns: fix static analysis warnings
* Original commit: espressif/esp-idf@c34de4cba6
2022-05-27 17:44:23 +04:00
98d2c1a073 mdns: fixed mdns crashing on reception of txt packet without a corresponding service
closes #2866


* Original commit: espressif/esp-idf@af48977f21
2022-05-27 17:44:23 +04:00
6ea0ea93fa mdns: use esp_event library to handle events
* Original commit: espressif/esp-idf@a2d59525e5
2022-05-27 17:44:23 +04:00
985e69117e mdns: fix possible crash when probing on particular interface with duplicated service instances due to naming conflicts on network
Issue: MDNS server initially sends probing packets to resolve naming confilicts with already registered service instances. In case of a conflict, instance name is altered and probing restarts. Original instance however wasnnot removed from the structure and upon service removal only one entry was removed and a dangling service might have been kept in the structure to bring about a crash.
Resolution: Keep only one instance of a service in the probing structure.

Closes IDF-498


* Original commit: espressif/esp-idf@265e983a45
2022-05-27 17:44:23 +04:00
75deebbf03 mdns: enable pcbs before starting service thread to avoid updating pcb's internal variables from concurent tasks
possible race condition: user task runs mdns_init, which enables pcbs while mdns-task already created could execute enable/disable of the same pcbs if an appropriate system event received


* Original commit: espressif/esp-idf@c87f0cb6ca
2022-05-27 17:44:23 +04:00
fdd27dc9fa mdns: fix possible deadlock on mdns deinit calling mdns_free()
mnds_free() initiates stop and delete timer tasks, which after locking the mutex could lead to a dead lock in case timer task executed before deleting the task, as it would wait indefinitelly for unlocking the mutex. This condition is fixed by calling _mdns_stop_timer without locking the mutex, because there's no need to protect any data when stopping and deleting the timer task

Closes https://github.com/espressif/esp-idf/issues/1696


* Original commit: espressif/esp-idf@48b5501c25
2022-05-27 17:44:23 +04:00
2ec3b558ea mdsn: fix race condition in updating packet data from user task when failed to allocate or queue a new service
Issue: mdns_service_add API allocates and queues an action to be processed in mdns task context; when allocation or queueing fails, allocated structure needs to be freed. Function _mdns_free_service did not only fee all the structures, but also updates packet data.
Resolution: Moved removal of packet data outside of _mdns_free_service function.


* Original commit: espressif/esp-idf@021dc5d453
2022-05-27 17:44:23 +04:00
450cbf03cf mdns: fix possible crash when packet scheduled to transmit contained service which might have been already removed
packets scheduled to transmit are pushed to action queue and removed from tx_queue_head structure, which is searched for all remaining services and while service is removed, then service questions/asnwers are also removed from this structure. This update fixes possible crash when packet is pushed to action queue, and when service is removed, its answers are removed from tx_queue_head, but not from action queue. this could lead to a crash when the packet is poped from action queue containing questions/answers to already removed (freed) service

Closes IDF-504


* Original commit: espressif/esp-idf@67051a286b
2022-05-27 17:44:23 +04:00
34f6d8dd33 mdns: use binary semaphore instead of mutex when searching
mdns_search_once_t::lock is used to synchronize tasks (taken by one
task and given by the other) so it should not be a mutex.
Convert to semaphore, and rename to indicate its purpose.


* Original commit: espressif/esp-idf@eef0b5090a
2022-05-27 17:44:22 +04:00
90e4babc61 mdns: fix malfuctional query_txt
when running a query for a single txt, result entries were not created and attached to result structure. this issue was introduced when fixing memory leak in txt structure, which worked correctly for PTR queries, but caused trouble for TXT query.


* Original commit: espressif/esp-idf@1a027734af
2022-05-27 17:44:22 +04:00
c546ab8dea mdns: fix possible crash when mdns_free called while action queue not empty
* Original commit: espressif/esp-idf@206b47c03a
2022-05-27 17:44:22 +04:00
6582b41cd1 mdns: fix memory leak when query for service receives multiple ptr entries for one instance
fixes redmine issue 27300


* Original commit: espressif/esp-idf@9a4da97fb4
2022-05-27 17:44:22 +04:00
358d26c8a1 mdns: fix crash after init if no memory for task
mdns init first starts timer task, then starts service task. if service task failed to be created, timer task needs to be stopped too.
fixed https://ezredmine.espressif.cn:8765/issues/28466


* Original commit: espressif/esp-idf@a47768dc4e
2022-05-27 17:44:22 +04:00
2ac83d0f27 mdns: fixed crash on free undefined ptr after skipped strdup
Shortcircuit evaluation may cause skip of _mdns_strdup_check of any further question field, which after clear_rx_packet freed undefined memory.
Fixes https://ezredmine.espressif.cn:8765/issues/28465


* Original commit: espressif/esp-idf@e0a8044a16
2022-05-27 17:44:22 +04:00
b30a7fec27 mdns: fixed static memory leak
* Original commit: espressif/esp-idf@6bb68a5a75
2022-05-27 17:44:22 +04:00
7a4fdad16d mdns: check all mallocs for failure and add default hook to log error with free heap
solves crash about _mdns_result_txt_create when stress test


* Original commit: espressif/esp-idf@c8cb4cd3c8
2022-05-27 17:44:22 +04:00
b4e57424f9 mdns: resolve memory leak when txt record received multiple times
* Original commit: espressif/esp-idf@a6b2b73f03
2022-05-27 17:44:22 +04:00
2763bcdb8d mdns: skip sending search when finished, not properly locked timer task
* Original commit: espressif/esp-idf@31163f02d5
2022-05-27 17:44:22 +04:00
8cd0e8a501 mdns: sending search packets also in probing and announcing state
mdns queries did not work properly when send imeadiately after set_hostname, which cuased reinit of pcb and therefore restarted probing, so search packets were blocked until probing finished
closes #2507, closes #2593


* Original commit: espressif/esp-idf@d16762a036
2022-05-27 17:44:22 +04:00
9b3b41c3f1 mdns: fixed crashes on network changes
1) two events AP_STOP, AP_START shortly after each other may cause IGMP config on already stopped netif
2) not properly locked sending packets to queue from timer task

closes #2580


* Original commit: espressif/esp-idf@097282a8e3
2022-05-27 17:44:22 +04:00
81c219d4ee feat(mdns): fix bug when clean action memory
* Original commit: espressif/esp-idf@3d4deb9726
2022-05-27 17:44:22 +04:00
0c17121ad7 bugfix: mdns_service_txt_set() wasn't allocating memory for TXT records
Allocation was happening later, causing possible use of stack variables
of caller function, which could be invalid.

Signed-off-by: Piyush Shah <piyush@espressif.com>


* Original commit: espressif/esp-idf@e5e2702ca3
2022-05-27 17:44:22 +04:00
b4ab30b5de mdns: Fix a portion of the queries are issued with the wildcard query type
* Original commit: espressif/esp-idf@f3f0445f4d
2022-05-27 17:44:22 +04:00
39de491597 mdns: Minor fix for mdns_service_remove()
Send the Goodbye packet while removing an mDNS service as an "Authoritative" packet so
that the listeners remove the service from their records immediately.


* Original commit: espressif/esp-idf@5c7eb7e27b
2022-05-27 17:44:22 +04:00
0191d6fcd7 fix(mdns): add the maximum number of services
* Original commit: espressif/esp-idf@ba458c69cf
2022-05-27 17:44:22 +04:00
b26c8665f8 fix(mdns): fix the exception when remove one of multiple service
* Original commit: espressif/esp-idf@696d733eb0
2022-05-27 17:44:22 +04:00
ad29d34bb6 Fixed nullptr dereference in MDNS.c
* Original commit: espressif/esp-idf@fffbf7b750
2022-05-27 17:44:22 +04:00
9f1be3668e MDNS-Fuzzer: AFL fuzzer tests for mdsn packet parser
* Original commit: espressif/esp-idf@e983230be9
2022-05-27 17:44:22 +04:00
7784d002fc Fix exception when service is removed while there are pending packets that depend on it
* Original commit: espressif/esp-idf@421c6f154b
2022-05-27 17:44:22 +04:00
bce7d5231c mdns: Fix case where service is NULL and that will cause exception
* Original commit: espressif/esp-idf@4fa130ae4f
2022-05-27 17:44:22 +04:00
ef924f1aa5 mdns: Fix issue with some mDNS parsers
Some mDNS parser have issue with zero terminated TXT lists. This fix targets to overcome this issue. Found and tested with jmdns.


* Original commit: espressif/esp-idf@51dde19a76
2022-05-27 17:44:22 +04:00
ad8c92db52 Import mDNS changes
* Original commit: espressif/esp-idf@4bddbc031c
2022-05-27 17:44:22 +04:00
3aa605fe24 Fix compilation errors when using gcc-7.2.0 for the crosstool-ng toolchain
* Change snprintf for strlcat does not complain w/gcc7.2.0 and it is safer, thanks @projectgus
* Use proper quotes for character literals

Merges https://github.com/espressif/esp-idf/pull/1163


* Original commit: espressif/esp-idf@519edc332d
2022-05-27 17:44:22 +04:00
00a72b8920 components/mdns: wrong Message compression detect
Old behavior assumes message compressed when any of 2 most significant bits are set,
But in fact Message compressed only when both those bits are set to 1.

Also maximal label length should be 63 bytes.


* Original commit: espressif/esp-idf@6e24566186
2022-05-27 17:44:22 +04:00
907e7ee29e mdns: fix leak after _mdns_create_service if we have a malloc error.
* Original commit: espressif/esp-idf@b6b36bd9dd
2022-05-27 17:44:22 +04:00
b367484361 Use LwIP IPC for low-level API calls
* Original commit: espressif/esp-idf@713964fe9e
2022-05-27 17:44:22 +04:00
4a8582f500 Add AFL fuzz test
* Original commit: espressif/esp-idf@4c2622755d
2022-05-27 17:44:22 +04:00
75de31cea3 implement fixes for issues found while fuzz testing
* Original commit: espressif/esp-idf@99d39909c4
2022-05-27 17:44:22 +04:00
4acf639afc mdns: add simple dns-sd meta query support
tabs to spaces

match domain


* Original commit: espressif/esp-idf@96e8a3c725
2022-05-27 17:44:22 +04:00
91bb5095f5 address security issues with mDNS
* Original commit: espressif/esp-idf@c89e11c8fa
2022-05-27 17:44:22 +04:00
7fbf8e5247 Initial mDNS component and example
* Original commit: espressif/esp-idf@dd3f18d2d8
2022-05-27 17:44:22 +04:00