summaryrefslogtreecommitdiff
path: root/sysdeps/mach/hurd/lseek.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/mach/hurd/lseek.c')
-rw-r--r--sysdeps/mach/hurd/lseek.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/sysdeps/mach/hurd/lseek.c b/sysdeps/mach/hurd/lseek.c
index 25e648bc8e..0a4077268a 100644
--- a/sysdeps/mach/hurd/lseek.c
+++ b/sysdeps/mach/hurd/lseek.c
@@ -1,4 +1,4 @@
-/* Copyright (C) 1991-2016 Free Software Foundation, Inc.
+/* Copyright (C) 1991-2018 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -17,12 +17,22 @@
#include <unistd.h>
#include <sys/types.h>
+#include <errno.h>
/* Seek to OFFSET on FD, starting from WHENCE. */
off_t
__libc_lseek (int fd, off_t offset, int whence)
{
- return __libc_lseek64 (fd, (off64_t) offset, whence);
+ off64_t res64 = __libc_lseek64 (fd, (off64_t) offset, whence);
+ off_t res = (off_t) res64;
+
+ if (sizeof res != sizeof res64 && res != res64)
+ {
+ __set_errno (EOVERFLOW);
+ return (off_t) -1;
+ }
+
+ return res;
}
weak_alias (__libc_lseek, __lseek)