From eeff60608c7aa65806c7c9f0ebddcf2520684ffa Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 18 Jul 2019 19:41:52 -0400 Subject: 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. --- src/stat/fstat.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/stat/fstat.c b/src/stat/fstat.c index d2a828f3..07f9a5de 100644 --- a/src/stat/fstat.c +++ b/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); } -- cgit v1.2.1