mirror of
https://github.com/espressif/esp-protocols.git
synced 2025-07-29 10:17:30 +02:00
fix(mdns): Fix use after free reported by coverity
Fixes CID 467739: Use after free in mdns.c, mdns_service_remove_for_host We should look only for one match in the service list, since if we assume there could be aliases, we might free one and reference the other.
This commit is contained in:
@ -6398,22 +6398,14 @@ esp_err_t mdns_service_remove_for_host(const char *instance, const char *service
|
||||
if (_mdns_service_match(a->service, service, proto, hostname)) {
|
||||
if (_mdns_server->services != a) {
|
||||
b->next = a->next;
|
||||
_mdns_send_bye(&a, 1, false);
|
||||
_mdns_remove_scheduled_service_packets(a->service);
|
||||
_mdns_free_service(a->service);
|
||||
free(a);
|
||||
a = b->next;
|
||||
continue;
|
||||
} else {
|
||||
_mdns_server->services = a->next;
|
||||
}
|
||||
_mdns_send_bye(&a, 1, false);
|
||||
_mdns_remove_scheduled_service_packets(a->service);
|
||||
_mdns_free_service(a->service);
|
||||
free(a);
|
||||
a = _mdns_server->services;
|
||||
b = a;
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
b = a;
|
||||
a = a->next;
|
||||
|
Reference in New Issue
Block a user