From 608f56ebf4b04d5ab97858f8d44caf46fd0ddff1 Mon Sep 17 00:00:00 2001 From: Alessio Pollero Date: Sat, 13 Feb 2021 18:15:45 +0000 Subject: [PATCH] Fix wifi SSID length to 33 since the maximum chars for SSID is 32 but the string is null terminated so array size must be 33 --- core/include/sdk_internal.h | 2 +- extras/wificfg/wificfg.c | 4 ++-- include/espressif/esp_softap.h | 2 +- include/espressif/esp_sta.h | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/include/sdk_internal.h b/core/include/sdk_internal.h index a4e21c6..4772f72 100644 --- a/core/include/sdk_internal.h +++ b/core/include/sdk_internal.h @@ -210,7 +210,7 @@ struct sdk_g_ic_volatile_st { struct sdk_g_ic_ssid_with_length { uint32_t ssid_length; // 0x1e4 sdk_wpa_config_profile - uint8_t ssid[32]; // 0x1e8 Station ssid. Null terminated string. + uint8_t ssid[33]; // 0x1e8 Station ssid. Null terminated string. }; // This is the portion of g_ic which is loaded/saved to the flash ROM, and thus diff --git a/extras/wificfg/wificfg.c b/extras/wificfg/wificfg.c index 1e4c5d2..3ea33ca 100644 --- a/extras/wificfg/wificfg.c +++ b/extras/wificfg/wificfg.c @@ -2057,7 +2057,7 @@ void wificfg_init(uint32_t port, const wificfg_dispatch *dispatch) sysparam_get_string("hostname", &hostname); if (!hostname && wificfg_default_hostname) { uint8_t macaddr[6]; - char name[32]; + char name[33]; sdk_wifi_get_macaddr(1, macaddr); snprintf(name, sizeof(name), wificfg_default_hostname, macaddr[3], macaddr[4], macaddr[5]); @@ -2108,7 +2108,7 @@ void wificfg_init(uint32_t port, const wificfg_dispatch *dispatch) /* Default AP ssid and password. */ if (!wifi_ap_ssid && wificfg_default_ssid) { uint8_t macaddr[6]; - char ssid[32]; + char ssid[33]; sdk_wifi_get_macaddr(1, macaddr); snprintf(ssid, sizeof(ssid), wificfg_default_ssid, macaddr[3], macaddr[4], macaddr[5]); diff --git a/include/espressif/esp_softap.h b/include/espressif/esp_softap.h index 8a81aef..586c45e 100644 --- a/include/espressif/esp_softap.h +++ b/include/espressif/esp_softap.h @@ -11,7 +11,7 @@ extern "C" { #endif struct sdk_softap_config { - uint8_t ssid[32]; + uint8_t ssid[33]; uint8_t password[64]; uint8_t ssid_len; uint8_t channel; diff --git a/include/espressif/esp_sta.h b/include/espressif/esp_sta.h index c5f585a..51f8ae5 100644 --- a/include/espressif/esp_sta.h +++ b/include/espressif/esp_sta.h @@ -15,7 +15,7 @@ extern "C" { #endif struct sdk_station_config { - uint8_t ssid[32]; /* Null terminated string */ + uint8_t ssid[33]; /* Null terminated string */ uint8_t password[64]; /* Null terminated string */ uint8_t bssid_set; /* One if bssid is used, otherwise zero. */ uint8_t bssid[6]; /* The BSSID bytes */ @@ -38,7 +38,7 @@ struct sdk_bss_info { STAILQ_ENTRY(sdk_bss_info) next; uint8_t bssid[6]; - uint8_t ssid[32]; + uint8_t ssid[33]; uint8_t channel; int8_t rssi; AUTH_MODE authmode;