fix(mdns): add terminator for the getting host name

This commit is contained in:
zwx
2023-10-31 19:33:41 +08:00
parent 418791cf79
commit b6a4d94ab0

View File

@ -5607,7 +5607,9 @@ esp_err_t mdns_hostname_get(char *hostname)
}
MDNS_SERVICE_LOCK();
strncpy(hostname, _mdns_server->hostname, strnlen(_mdns_server->hostname, MDNS_NAME_BUF_LEN));
size_t len = strnlen(_mdns_server->hostname, MDNS_NAME_BUF_LEN - 1);
strncpy(hostname, _mdns_server->hostname, len);
hostname[len] = 0;
MDNS_SERVICE_UNLOCK();
return ESP_OK;
}