Browse Source

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

www220@tom.com 9 years ago
parent
commit
45d46b076f
1 changed files with 2 additions and 1 deletions
  1. 2 1
      components/dfs/filesystems/romfs/dfs_romfs.c

+ 2 - 1
components/dfs/filesystems/romfs/dfs_romfs.c

@@ -96,7 +96,8 @@ struct romfs_dirent *dfs_romfs_lookup(struct romfs_dirent *root_dirent, const ch
 		{
             if (check_dirent(&dirent[index]) != 0)
                 return RT_NULL;
-			if (rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0)
+			if (rt_strlen(dirent[index].name) == (subpath_end - subpath) &&
+					rt_strncmp(dirent[index].name, subpath, (subpath_end - subpath)) == 0)
 			{
 				dirent_size = dirent[index].size;