瀏覽代碼

restore property that fstat(AT_FDCWD) fails with EBADF

AT_FDCWD is not a valid file descriptor, so POSIX requires fstat to
fail with EBADF. if passed to fstatat, the call would spuriously
succeed and return results for the working directory.
Rich Felker 5 年之前
父節點
當前提交
eeff60608c
共有 1 個文件被更改,包括 1 次插入0 次删除
  1. 1 0
      src/stat/fstat.c

+ 1 - 0
src/stat/fstat.c

@@ -6,6 +6,7 @@
 
 int fstat(int fd, struct stat *st)
 {
+	if (fd<0) return __syscall_ret(-EBADF);
 	return fstatat(fd, "", st, AT_EMPTY_PATH);
 }