esp8266/modnetwork: In connect, fix potential buffer overflows.

This commit is contained in:
puuu 2017-05-11 11:50:01 +09:00 committed by Damien George
parent 162a0f942b
commit 4b235800a4
1 changed files with 3 additions and 3 deletions

View File

@ -102,13 +102,13 @@ STATIC mp_obj_t esp_connect(mp_uint_t n_args, const mp_obj_t *args) {
if (n_args > 1) { if (n_args > 1) {
p = mp_obj_str_get_data(args[1], &len); p = mp_obj_str_get_data(args[1], &len);
len = MIN(len, sizeof(config.ssid));
memcpy(config.ssid, p, len); memcpy(config.ssid, p, len);
if (n_args > 2) { if (n_args > 2) {
p = mp_obj_str_get_data(args[2], &len); p = mp_obj_str_get_data(args[2], &len);
} else { len = MIN(len, sizeof(config.password));
p = ""; memcpy(config.password, p, len);
} }
memcpy(config.password, p, len);
error_check(wifi_station_set_config(&config), "Cannot set STA config"); error_check(wifi_station_set_config(&config), "Cannot set STA config");
} }