From 4b235800a4ebba19a98bba50a5a98d2c407d99a7 Mon Sep 17 00:00:00 2001 From: puuu Date: Thu, 11 May 2017 11:50:01 +0900 Subject: [PATCH] esp8266/modnetwork: In connect, fix potential buffer overflows. --- esp8266/modnetwork.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/esp8266/modnetwork.c b/esp8266/modnetwork.c index 627655b369..eb9d75e284 100644 --- a/esp8266/modnetwork.c +++ b/esp8266/modnetwork.c @@ -102,13 +102,13 @@ STATIC mp_obj_t esp_connect(mp_uint_t n_args, const mp_obj_t *args) { if (n_args > 1) { p = mp_obj_str_get_data(args[1], &len); + len = MIN(len, sizeof(config.ssid)); memcpy(config.ssid, p, len); if (n_args > 2) { p = mp_obj_str_get_data(args[2], &len); - } else { - p = ""; + len = MIN(len, sizeof(config.password)); + memcpy(config.password, p, len); } - memcpy(config.password, p, len); error_check(wifi_station_set_config(&config), "Cannot set STA config"); }