From 352f4997fa633cd05aa499dcdeb55a75870c0dad Mon Sep 17 00:00:00 2001 From: Euripedes Rocha Filho Date: Fri, 3 Jul 2026 10:55:28 +0200 Subject: [PATCH] fix(esp_netif): reject NULL hostname in esp_netif_set_hostname_api esp_netif_set_hostname_api() dereferenced hostname via strlen() without checking it for NULL first, causing a NULL pointer dereference. --- components/esp_netif/lwip/esp_netif_lwip.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/components/esp_netif/lwip/esp_netif_lwip.c b/components/esp_netif/lwip/esp_netif_lwip.c index 4512b66f2d3..9ebce71a347 100644 --- a/components/esp_netif/lwip/esp_netif_lwip.c +++ b/components/esp_netif/lwip/esp_netif_lwip.c @@ -1750,12 +1750,12 @@ static esp_err_t esp_netif_set_hostname_api(esp_netif_api_msg_t *msg) esp_netif_t *esp_netif = msg->esp_netif; const char *hostname = msg->data; - ESP_LOGD(TAG, "%s esp_netif:%p hostname %s", __func__, esp_netif, hostname); - - if (!esp_netif) { + if (!esp_netif || hostname == NULL) { return ESP_ERR_INVALID_ARG; } + ESP_LOGV(TAG, "%s esp_netif:%p hostname %s", __func__, esp_netif, hostname); + #if LWIP_NETIF_HOSTNAME struct netif *p_netif = esp_netif->lwip_netif;