Skip to content

Commit 45d46b0

Browse files
修正romfs在输入的目录名称比实际的名称短时存在的判断错误
比如实际目录为abcde,msh执行 cd abc也能执行成功,判断名称时存在bug
1 parent c7af45b commit 45d46b0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

components/dfs/filesystems/romfs/dfs_romfs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch
9696
{
9797
if (check_dirent(&dirent[index]) != 0)
9898
return RT_NULL;
99-
if (rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0)
99+
if (rt_strlen(dirent[index].name) == (subpath_end - subpath) &&
100+
rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0)
100101
{
101102
dirent_size = dirent[index].size;
102103

0 commit comments

Comments
 (0)