diff --git a/components/dfs/src/dfs.c b/components/dfs/src/dfs.c index bfe9942f4790f9331d0169c7c272a4b08985e9c3..71ebc0b197cbdf804ccd09b3d7d0882bd5bb9414 100644 --- a/components/dfs/src/dfs.c +++ b/components/dfs/src/dfs.c @@ -655,11 +655,16 @@ char *dfs_normalize_path(const char *directory, const char *filename) continue; up_one: - dst--; - if (dst < dst0) + /* keep the topmost root directory */ + if (dst - dst0 != 1 || dst[-1] != '/') { - rt_free(fullpath); - return NULL; + dst--; + + if (dst < dst0) + { + rt_free(fullpath); + return NULL; + } } while (dst0 < dst && dst[-1] != '/') dst--;