Merge pull request #1586 from zhaojuntao/wlan-fix-pwd

[drivers/wlan] Fix the problem that the password is empty
This commit is contained in:
Bernard Xiong 2018-06-29 22:19:47 +08:00 committed by GitHub
commit 5b863eb89b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 12 additions and 1 deletions

View File

@ -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);