Skip to content

Commit ebdac9c

Browse files
authored
Merge pull request espressif#409 from zwx1995esp/fix/mdns_host_name_get
fix(mdns): add terminator for the getting host name
2 parents df04b14 + b6a4d94 commit ebdac9c

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

components/mdns/mdns.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5613,7 +5613,9 @@ esp_err_t mdns_hostname_get(char *hostname)
56135613
}
56145614

56155615
MDNS_SERVICE_LOCK();
5616-
strncpy(hostname, _mdns_server->hostname, strnlen(_mdns_server->hostname, MDNS_NAME_BUF_LEN));
5616+
size_t len = strnlen(_mdns_server->hostname, MDNS_NAME_BUF_LEN - 1);
5617+
strncpy(hostname, _mdns_server->hostname, len);
5618+
hostname[len] = 0;
56175619
MDNS_SERVICE_UNLOCK();
56185620
return ESP_OK;
56195621
}

0 commit comments

Comments
 (0)