summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMurphyZhao <[email protected]>2018-06-29 14:56:19 +0800
committerMurphyZhao <[email protected]>2018-06-29 14:57:13 +0800
commit6a85a624d7117dbedee27fcd2b337eb3797cc342 (patch)
tree9e5ece0609e412f0abb9243db3a85ef10dbaa6d1
parent0f3820f1b671c56143e8417d4e332b035a7da176 (diff)
[drivers/wlan] Fix the problem that the password is empty
Signed-off-by: MurphyZhao <[email protected]>
-rw-r--r--components/drivers/wlan/wlan_dev.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/components/drivers/wlan/wlan_dev.c b/components/drivers/wlan/wlan_dev.c
index 3c26531508..a42072692c 100644
--- a/components/drivers/wlan/wlan_dev.c
+++ b/components/drivers/wlan/wlan_dev.c
@@ -117,7 +117,18 @@ int rt_wlan_softap(struct rt_wlan_device *device, struct rt_wlan_info *info, cha
rt_wlan_set_info(device, info);
}
- rt_strncpy((char *)device->key, (char *)password, sizeof(device->key) - 1);
+ if (password == NULL)
+ {
+ memset(device->key, 0, sizeof(device->key));
+ }
+ else
+ {
+ if (rt_strlen(password) > sizeof(device->key) - 1)
+ {
+ rt_kprintf("WARN input password is longer than %d bytes.", sizeof(device->key) - 1);
+ }
+ rt_strncpy((char *)device->key, (char *)password, sizeof(device->key) - 1);
+ }
result = rt_device_control(RT_DEVICE(device), WIFI_SOFTAP, (void *)password);