risc-v/esp32c3: Fix the issue of getting wrong Wi-Fi password

This commit is contained in:
chenwen 2021-04-09 11:48:01 +08:00 committed by Xiang Xiao
parent f2a57b612a
commit 4ca34ac5b5
2 changed files with 15 additions and 11 deletions

View File

@ -5120,13 +5120,6 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set)
DEBUGASSERT(ext != NULL);
pdata = ext->key;
len = ext->key_len;
if (set && len > PWD_MAX_LEN)
{
return -EINVAL;
}
memset(&wifi_cfg, 0x0, sizeof(wifi_config_t));
ret = esp_wifi_get_config(WIFI_IF_STA, &wifi_cfg);
if (ret)
@ -5137,6 +5130,12 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set)
if (set)
{
len = ext->key_len;
if (len > PWD_MAX_LEN)
{
return -EINVAL;
}
memcpy(wifi_cfg.sta.password, pdata, len);
wifi_cfg.sta.pmf_cfg.capable = true;
@ -5150,6 +5149,7 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set)
}
else
{
len = iwr->u.encoding.length - sizeof(*ext);
size = strnlen((char *)wifi_cfg.sta.password, PWD_MAX_LEN);
if (len < size)
{
@ -5157,8 +5157,8 @@ int esp_wifi_sta_password(struct iwreq *iwr, bool set)
}
else
{
len = size;
memcpy(pdata, wifi_cfg.sta.password, len);
ext->key_len = size;
memcpy(pdata, wifi_cfg.sta.password, ext->key_len);
}
if (g_sta_connected)
@ -5862,7 +5862,7 @@ int esp_wifi_sta_country(struct iwreq *iwr, bool set)
country_code = (char *)iwr->u.data.pointer;
if (strlen(country_code) != 2)
{
wlerr("ERROR: Invalid input arguments\r\n");
wlerr("ERROR: Invalid input arguments\n");
return -EINVAL;
}

View File

@ -271,6 +271,10 @@ static int wlan_sta_set_linkstatus(FAR struct net_driver_s *dev,
bool linkstatus);
#endif
#ifdef CONFIG_NET_ICMPv6
static void wlan_ipv6multicast(FAR struct wlan_priv_s *priv);
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
@ -1215,7 +1219,7 @@ static int wlan_ifup(FAR struct net_driver_s *dev)
(uint8_t)(dev->d_ipaddr >> 16), (uint8_t)(dev->d_ipaddr >> 24));
#endif
#ifdef CONFIG_NET_IPv6
winfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
ninfo("Bringing up: %04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x\n",
dev->d_ipv6addr[0], dev->d_ipv6addr[1], dev->d_ipv6addr[2],
dev->d_ipv6addr[3], dev->d_ipv6addr[4], dev->d_ipv6addr[5],
dev->d_ipv6addr[6], dev->d_ipv6addr[7]);