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