fix(mdns): Allow setting instance name only after hostname set

Closes https://github.com/espressif/esp-protocols/issues/190
This commit is contained in:
David Cermak
2023-01-20 10:46:41 +01:00
parent 12cfcb5aed
commit a8339e4618
2 changed files with 9 additions and 1 deletions

View File

@ -5398,7 +5398,7 @@ esp_err_t mdns_instance_name_set(const char *instance)
if (!_mdns_server) {
return ESP_ERR_INVALID_STATE;
}
if (_str_null_or_empty(instance) || strlen(instance) > (MDNS_NAME_BUF_LEN - 1)) {
if (_str_null_or_empty(instance) || _mdns_server->hostname == NULL || strlen(instance) > (MDNS_NAME_BUF_LEN - 1)) {
return ESP_ERR_INVALID_ARG;
}
char *new_instance = strndup(instance, MDNS_NAME_BUF_LEN - 1);