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:
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user