Explorar o código

!296 修复syscall中存在的bug
Merge pull request !296 from 井底的蛙/sys_call_fix

bernard %!s(int64=4) %!d(string=hai) anos
pai
achega
0de223ff34
Modificáronse 1 ficheiros con 9 adicións e 2 borrados
  1. 9 2
      components/lwp/lwp_syscall.c

+ 9 - 2
components/lwp/lwp_syscall.c

@@ -3349,8 +3349,8 @@ int sys_getdents(int fd, struct libc_dirent *dirp, size_t nbytes)
         return -1;
     }
     dfs_fd = fd_get(fd);
-    ret = dfs_file_getdents(dfs_fd, rtt_dirp, nbytes);
-    if (ret)
+    ret = dfs_file_getdents(dfs_fd, rtt_dirp, rtt_nbytes);
+    if (ret > 0)
     {
         size_t i = 0;
         cnt = ret / sizeof(struct dirent);
@@ -3420,6 +3420,13 @@ int sys_access(const char *filename, int mode)
         ret = -1;
     }
 
+    len = rt_strlen(filename);
+    if (!len)
+    {
+        rt_set_errno(EINVAL);
+        return -1;
+    }
+
     kname = (char *)kmem_get(len + 1);
     if (!ret && !kname)
     {