about summary refs log tree commit diff
path: root/src/stat
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2019-07-18 19:41:52 -0400
committerRich Felker <dalias@aerifal.cx>2019-07-18 19:47:46 -0400
commiteeff60608c7aa65806c7c9f0ebddcf2520684ffa (patch)
treef8632785fb8ebefa892f15fe1e05b02091de6b07 /src/stat
parentfa7d4218c7038cb4bd29cbdf693306118b324030 (diff)
downloadmusl-eeff60608c7aa65806c7c9f0ebddcf2520684ffa.tar.gz
musl-eeff60608c7aa65806c7c9f0ebddcf2520684ffa.tar.xz
musl-eeff60608c7aa65806c7c9f0ebddcf2520684ffa.zip
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.
Diffstat (limited to 'src/stat')
-rw-r--r--src/stat/fstat.c1
1 files changed, 1 insertions, 0 deletions
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);
 }