WINC: Check for empty SSID and/or key.
@@ -97,6 +97,10 @@ static mp_obj_t py_winc_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
// get ssid
const char *ssid = mp_obj_str_get_str(args[0].u_obj);
+ if (strlen(ssid) == 0) {
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "SSID can't be empty!"));
+ }
+
// get key and sec
const char *key = NULL;
mp_uint_t security = M2M_WIFI_SEC_OPEN;
@@ -106,6 +110,10 @@ static mp_obj_t py_winc_connect(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
security = args[2].u_int;
}
+ if (security != M2M_WIFI_SEC_OPEN && strlen(key) == 0) {
+ nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "Key can't be empty!"));
+ }
+
// connect to AP
if (winc_connect(ssid, security, key, M2M_WIFI_CH_ALL) != 0) {
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError,
