Skip to content

Commit 4b23580

Browse files
puuudpgeorge
authored andcommitted
esp8266/modnetwork: In connect, fix potential buffer overflows.
1 parent 162a0f9 commit 4b23580

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

esp8266/modnetwork.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,13 +102,13 @@ STATIC mp_obj_t esp_connect(mp_uint_t n_args, const mp_obj_t *args) {
102102

103103
if (n_args > 1) {
104104
p = mp_obj_str_get_data(args[1], &len);
105+
len = MIN(len, sizeof(config.ssid));
105106
memcpy(config.ssid, p, len);
106107
if (n_args > 2) {
107108
p = mp_obj_str_get_data(args[2], &len);
108-
} else {
109-
p = "";
109+
len = MIN(len, sizeof(config.password));
110+
memcpy(config.password, p, len);
110111
}
111-
memcpy(config.password, p, len);
112112

113113
error_check(wifi_station_set_config(&config), "Cannot set STA config");
114114
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy