Skip to content

Commit d2cc7c7

Browse files
committed
extmod/modwebrepl: set_password(): Raise exception for too long password.
1 parent 095e43a commit d2cc7c7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

extmod/modwebrepl.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -310,9 +310,10 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(webrepl_close_obj, webrepl_close);
310310
STATIC mp_obj_t webrepl_set_password(mp_obj_t passwd_in) {
311311
mp_uint_t len;
312312
const char *passwd = mp_obj_str_get_data(passwd_in, &len);
313-
len = MIN(len, sizeof(webrepl_passwd) - 1);
314-
memcpy(webrepl_passwd, passwd, len);
315-
webrepl_passwd[len] = 0;
313+
if (len > sizeof(webrepl_passwd) - 1) {
314+
mp_raise_ValueError("");
315+
}
316+
strcpy(webrepl_passwd, passwd);
316317
return mp_const_none;
317318
}
318319
STATIC MP_DEFINE_CONST_FUN_OBJ_1(webrepl_set_password_obj, webrepl_set_password);

0 commit comments

Comments
 (0)