浏览代码

check dfs_fd valid in close

git-svn-id: https://rt-thread.googlecode.com/svn/trunk@2539 bbd45198-f89e-11dd-88c7-29a3b14d5316
goprife@gmail.com 12 年之前
父节点
当前提交
1c419d428e
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      components/dfs/src/dfs_posix.c

+ 7 - 0
components/dfs/src/dfs_posix.c

@@ -86,6 +86,13 @@ int close(int fd)
         return -1;
     }
 
+    /* check dfs_fd valid or not */
+    if (d->path == RT_NULL || d->ref_count == 0)
+    {
+        rt_set_errno(-DFS_STATUS_EBADF);
+        return -1;
+    }
+
     result = dfs_file_close(d);
     fd_put(d);