Commit graph

43 commits

Author SHA1 Message Date
suda-morris
90c4827bd2 add esp_eth component 2019-06-26 10:19:23 +08:00
David Cermak
c34de4cba6 mdns: fix static analysis warnings 2019-06-10 13:21:07 +00:00
David Cermak
af48977f21 mdns: fixed mdns crashing on reception of txt packet without a corresponding service
closes #2866
2019-05-03 16:37:43 +02:00
Ivan Grokhotkov
a2d59525e5 mdns: use esp_event library to handle events 2019-04-11 12:04:58 +08:00
David Cermak
265e983a45 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
2019-03-13 10:22:41 +01:00
David Cermak
c87f0cb6ca 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
2019-03-13 10:22:41 +01:00
David Cermak
48b5501c25 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
2019-03-13 10:22:41 +01:00
David Cermak
021dc5d453 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.
2019-03-13 10:22:41 +01:00
David Cermak
67051a286b 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
2019-03-13 10:22:41 +01:00
Ivan Grokhotkov
eef0b5090a 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.
2019-03-12 09:33:06 +01:00
David Cermak
1a027734af 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.
2019-02-15 13:46:51 +01:00
David Cermak
206b47c03a mdns: fix possible crash when mdns_free called while action queue not empty 2019-02-15 13:23:21 +01:00
David Cermak
9a4da97fb4 mdns: fix memory leak when query for service receives multiple ptr entries for one instance
fixes redmine issue 27300
2019-02-15 07:56:03 +01:00
David Cermak
a47768dc4e 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
2019-01-30 08:17:37 +01:00
David Cermak
e0a8044a16 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
2019-01-29 10:10:38 +01:00
David Cermak
6bb68a5a75 mdns: fixed static memory leak 2018-12-17 12:09:23 +01:00
David Cermak
c8cb4cd3c8 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
2018-12-17 12:09:11 +01:00
David Cermak
a6b2b73f03 mdns: resolve memory leak when txt record received multiple times 2018-12-11 21:59:44 +01:00
David Cermak
31163f02d5 mdns: skip sending search when finished, not properly locked timer task 2018-12-11 21:56:01 +01:00
David Cermak
d16762a036 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
2018-11-16 07:22:29 +00:00
David Cermak
097282a8e3 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
2018-10-24 12:03:41 +02:00
Liu Han
3d4deb9726 feat(mdns): fix bug when clean action memory 2018-09-14 15:36:52 +08:00
Piyush Shah
e5e2702ca3 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>
2018-09-11 16:23:56 +05:30
Liu Han
f3f0445f4d mdns: Fix a portion of the queries are issued with the wildcard query type 2018-08-14 07:25:08 +00:00
Piyush Shah
5c7eb7e27b 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.
2018-07-12 19:18:54 +05:30
Liu Han
ba458c69cf fix(mdns): add the maximum number of services 2018-06-21 10:31:09 +08:00
Liu Han
696d733eb0 fix(mdns): fix the exception when remove one of multiple service 2018-06-03 17:29:49 +08:00
David Cermak
fffbf7b750 Fixed nullptr dereference in MDNS.c 2018-05-22 11:23:12 +02:00
David Cermak
e983230be9 MDNS-Fuzzer: AFL fuzzer tests for mdsn packet parser 2018-05-22 11:23:12 +02:00
me-no-dev
421c6f154b Fix exception when service is removed while there are pending packets that depend on it 2018-04-09 09:40:08 +03:00
me-no-dev
4fa130ae4f mdns: Fix case where service is NULL and that will cause exception 2018-01-22 13:56:53 +01:00
me-no-dev
51dde19a76 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.
2018-01-22 13:56:34 +01:00
me-no-dev
4bddbc031c Import mDNS changes 2018-01-16 10:58:34 +02:00
Roman Valls Guimera
519edc332d 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
2017-12-04 10:18:40 +11:00
Siarhei Volkau
6e24566186 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.
2017-11-03 16:52:22 +08:00
Ivan Grokhotkov
b4857fc159 Merge branch 'bugfix/memory_issues_pr838' into 'master'
vfat, i2s, mdns: Fix two memory leaks, one double free (github #838)

See merge request !1173
2017-08-31 10:45:19 +08:00
Quentin Thérond
b6b36bd9dd mdns: fix leak after _mdns_create_service if we have a malloc error. 2017-08-30 12:11:57 +10:00
Eugene Zagidullin
713964fe9e Use LwIP IPC for low-level API calls 2017-06-27 00:41:41 +03:00
me-no-dev
4c2622755d Add AFL fuzz test 2017-04-05 09:23:09 +03:00
me-no-dev
99d39909c4 implement fixes for issues found while fuzz testing 2017-04-03 16:45:59 +03:00
negativekelvin
96e8a3c725 mdns: add simple dns-sd meta query support
tabs to spaces

match domain
2017-03-29 11:48:19 +11:00
me-no-dev
c89e11c8fa address security issues with mDNS 2017-03-14 10:08:38 +02:00
me-no-dev
dd3f18d2d8 Initial mDNS component and example 2017-01-13 12:12:43 +02:00