diff options
author | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-03-11 08:21:06 -0300 |
---|---|---|
committer | Adhemerval Zanella <adhemerval.zanella@linaro.org> | 2021-03-11 10:51:55 -0300 |
commit | 94caafa040e4b4289c968cd70d53041b1463ac4d (patch) | |
tree | 3cf4b0cecd7a112f32fb6a9756f0203eac635cd7 /io/fstat.c | |
parent | e91f44089c3203f647d6feadb958ff5f388427bd (diff) | |
download | glibc-94caafa040e4b4289c968cd70d53041b1463ac4d.zip glibc-94caafa040e4b4289c968cd70d53041b1463ac4d.tar.gz glibc-94caafa040e4b4289c968cd70d53041b1463ac4d.tar.bz2 |
io: Return EBAFD for negative file descriptor on fstat (BZ #27559)
Now that fstat is implemented on top fstatat we need to handle negative
inputs. The implementation now rejects AT_FDCWD, which would otherwise
be accepted by the kernel.
Checked on x86_64-linux-gnu and on i686-linux-gnu.
Diffstat (limited to 'io/fstat.c')
-rw-r--r-- | io/fstat.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -16,10 +16,16 @@ <https://www.gnu.org/licenses/>. */ #include <sys/stat.h> +#include <errno.h> int __fstat (int fd, struct stat *buf) { + if (fd < 0) + { + __set_errno (EBADF); + return -1; + } return __fstatat (fd, "", buf, AT_EMPTY_PATH); } |