From ee8e4116d3903a444ade56e9fe360d96ab76ae36 Mon Sep 17 00:00:00 2001 From: Junwha Date: Wed, 3 Jan 2024 02:25:28 +0900 Subject: [PATCH] fix: Compare mount string by min length. Signed-off-by: Junwha --- extmod/vfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extmod/vfs.c b/extmod/vfs.c index af63ceb37e..1285fa3bc5 100644 --- a/extmod/vfs.c +++ b/extmod/vfs.c @@ -273,7 +273,7 @@ mp_obj_t mp_vfs_umount(mp_obj_t mnt_in) { mnt_str = mp_obj_str_get_data(mnt_in, &mnt_len); } for (mp_vfs_mount_t **vfsp = &MP_STATE_VM(vfs_mount_table); *vfsp != NULL; vfsp = &(*vfsp)->next) { - if ((mnt_str != NULL && !memcmp(mnt_str, (*vfsp)->str, mnt_len + 1)) || (*vfsp)->obj == mnt_in) { + if ((mnt_str != NULL && !memcmp(mnt_str, (*vfsp)->str, (((*vfsp)->len < mnt_len + 1) ? (*vfsp)->len : mnt_len + 1))) || (*vfsp)->obj == mnt_in) { vfs = *vfsp; *vfsp = (*vfsp)->next; break;