Merge pull request #8201 from dhalbert/8.2.x-backport-8150-set-hostname

8.2.x backport: fix set hostname
This commit is contained in:
Scott Shawcroft 2023-07-24 09:48:33 -07:00 committed by GitHub
commit f902e0d86b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -88,7 +88,7 @@ mp_obj_t common_hal_wifi_radio_get_hostname(wifi_radio_obj_t *self) {
void common_hal_wifi_radio_set_hostname(wifi_radio_obj_t *self, const char *hostname) {
assert(strlen(hostname) < MP_ARRAY_SIZE(self->hostname));
memcpy(self->hostname, hostname, strlen(hostname));
strncpy(self->hostname, hostname, MP_ARRAY_SIZE(self->hostname) - 1);
netif_set_hostname(NETIF_STA, self->hostname);
netif_set_hostname(NETIF_AP, self->hostname);
}