]> granicus.if.org Git - esp-idf/commitdiff
lwip: Use strlcpy() instead of memcpy() to copy hostname to static buffer
authorAngus Gratton <angus@espressif.com>
Thu, 2 Mar 2017 03:50:58 +0000 (14:50 +1100)
committerAngus Gratton <angus@espressif.com>
Fri, 17 Mar 2017 10:12:41 +0000 (18:12 +0800)
components/tcpip_adapter/tcpip_adapter_lwip.c

index 6e166175479944c3df9231d93c3e19993124c122..c98825ec6bef323ce1e6acec51496d547d3188cd 100644 (file)
@@ -726,7 +726,7 @@ esp_err_t tcpip_adapter_set_hostname(tcpip_adapter_if_t tcpip_if, const char *ho
     p_netif = esp_netif[tcpip_if];
     if (p_netif != NULL) {
         memset(hostinfo[tcpip_if], 0, sizeof(hostinfo[tcpip_if]));
-        memcpy(hostinfo[tcpip_if], hostname, strlen(hostname));
+        strlcpy(hostinfo[tcpip_if], hostname, sizeof(hostinfo[tcpip_if]));
         p_netif->hostname = hostinfo[tcpip_if];
         return ESP_OK;
     } else {