aboutsummaryrefslogtreecommitdiff
path: root/io/fstat.c
diff options
context:
space:
mode:
Diffstat (limited to 'io/fstat.c')
-rw-r--r--io/fstat.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/io/fstat.c b/io/fstat.c
index dc11736..17f31bf 100644
--- a/io/fstat.c
+++ b/io/fstat.c
@@ -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);
}