esp8266/modnetwork: Raise ValueError when getting invalid WLAN id.

Instead of crashing due to out-of-bounds array access.  Fixes #3348.
pull/3791/head
Damien George 2018-05-17 22:12:24 +10:00
rodzic f8a5cd24d8
commit dd13065843
1 zmienionych plików z 3 dodań i 0 usunięć

Wyświetl plik

@ -65,6 +65,9 @@ STATIC mp_obj_t get_wlan(size_t n_args, const mp_obj_t *args) {
int idx = 0;
if (n_args > 0) {
idx = mp_obj_get_int(args[0]);
if (idx < 0 || idx >= sizeof(wlan_objs)) {
mp_raise_ValueError(NULL);
}
}
return MP_OBJ_FROM_PTR(&wlan_objs[idx]);
}