Skip to content

REALTEK_RTL8195AM Wifi driver - adds check of credentials validity #5577

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 12, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,25 @@ nsapi_error_t RTWInterface::set_dhcp(bool dhcp)
*/
nsapi_error_t RTWInterface::set_credentials(const char *ssid, const char *pass, nsapi_security_t security)
{
if(!ssid) {
return NSAPI_ERROR_PARAMETER;
}

switch (security) {
case NSAPI_SECURITY_WPA:
case NSAPI_SECURITY_WPA2:
case NSAPI_SECURITY_WPA_WPA2:
case NSAPI_SECURITY_WEP:
if((strlen(pass) < 8) || (strlen(pass) > 63)) { // 802.11 password 8-63 characters
return NSAPI_ERROR_PARAMETER;
}
break;
case NSAPI_SECURITY_NONE:
break;
default:
return NSAPI_ERROR_PARAMETER;
}

strncpy(_ssid, ssid, 255);
strncpy(_pass, pass, 255);
_security = security;
Expand Down Expand Up @@ -281,4 +300,4 @@ const char *RTWInterface::get_gateway()
NetworkStack *RTWInterface::get_stack()
{
return nsapi_create_stack(&lwip_stack);
}
}