Skip to content

Commit 2994354

Browse files
junwhadpgeorge
authored andcommitted
extmod/vfs: Fix buffer overflow of string comparison in umount.
The comparison between the given unmount string and existing mount strings were made by the given string, which leads to buffer overflow. Fixes issue micropython#13006. Signed-off-by: Junwha <[email protected]>
1 parent 390390e commit 2994354

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

extmod/vfs.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) {
273273
mnt_str = mp_obj_str_get_data(mnt_in, &mnt_len);
274274
}
275275
for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) {
276-
if ((mnt_str != NULL && !memcmp(mnt_str, (*vfsp)->str, mnt_len + 1)) || (*vfsp)->obj == mnt_in) {
276+
if ((mnt_str != NULL && mnt_len == (*vfsp)->len && !memcmp(mnt_str, (*vfsp)->str, mnt_len)) || (*vfsp)->obj == mnt_in) {
277277
vfs = *vfsp;
278278
*vfsp = (*vfsp)->next;
279279
break;

0 commit comments

Comments
 (0)