projects
/
oweals
/
musl.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
fa7d421
)
restore property that fstat(AT_FDCWD) fails with EBADF
author
Rich Felker
<dalias@aerifal.cx>
Thu, 18 Jul 2019 23:41:52 +0000
(19:41 -0400)
committer
Rich Felker
<dalias@aerifal.cx>
Thu, 18 Jul 2019 23:47:46 +0000
(19:47 -0400)
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
patch
|
blob
|
history
diff --git
a/src/stat/fstat.c
b/src/stat/fstat.c
index d2a828f32c64bf4686e995672243f1c8ce77766d..07f9a5de15e8a54b4f7b1c37ddcb0119190fef5b 100644
(file)
--- 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);
}