Skip to content

Commit aff1d30

Browse files
authored
Merge pull request #5577 from VeijoPesonen/realtek_rtl8195am_gt_wifi-set-credential
REALTEK_RTL8195AM Wifi driver - adds check of credentials validity
2 parents 6c59e13 + ee77079 commit aff1d30

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

targets/TARGET_Realtek/TARGET_AMEBA/RTWInterface.cpp

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,25 @@ nsapi_error_t RTWInterface::set_dhcp(bool dhcp)
130130
*/
131131
nsapi_error_t RTWInterface::set_credentials(const char *ssid, const char *pass, nsapi_security_t security)
132132
{
133+
if(!ssid) {
134+
return NSAPI_ERROR_PARAMETER;
135+
}
136+
137+
switch (security) {
138+
case NSAPI_SECURITY_WPA:
139+
case NSAPI_SECURITY_WPA2:
140+
case NSAPI_SECURITY_WPA_WPA2:
141+
case NSAPI_SECURITY_WEP:
142+
if((strlen(pass) < 8) || (strlen(pass) > 63)) { // 802.11 password 8-63 characters
143+
return NSAPI_ERROR_PARAMETER;
144+
}
145+
break;
146+
case NSAPI_SECURITY_NONE:
147+
break;
148+
default:
149+
return NSAPI_ERROR_PARAMETER;
150+
}
151+
133152
strncpy(_ssid, ssid, 255);
134153
strncpy(_pass, pass, 255);
135154
_security = security;
@@ -281,4 +300,4 @@ const char *RTWInterface::get_gateway()
281300
NetworkStack *RTWInterface::get_stack()
282301
{
283302
return nsapi_create_stack(&lwip_stack);
284-
}
303+
}

0 commit comments

Comments
 (0)