1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-12-24 17:51:17 +03:00

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.
This commit is contained in:
Adhemerval Zanella
2021-03-11 08:21:06 -03:00
parent e91f44089c
commit 94caafa040
7 changed files with 135 additions and 1 deletions

View File

@@ -19,11 +19,17 @@
#include <sys/stat.h>
#include <kernel_stat.h>
#include <fcntl.h>
#include <errno.h>
#if !XSTAT_IS_XSTAT64
int
__fstat (int fd, struct stat *buf)
{
if (fd < 0)
{
__set_errno (EBADF);
return -1;
}
return __fstatat (fd, "", buf, AT_EMPTY_PATH);
}