From: Samuel Thibault Date: Fri, 15 Jun 2018 23:00:00 +0000 (+0200) Subject: hurd: Detect 32bit overflow in value returned by lseek X-Git-Tag: glibc-2.28~198 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=faf7bbc2d051f7351af5761e3f84f1c3c8b6479f;p=thirdparty%2Fglibc.git hurd: Detect 32bit overflow in value returned by lseek * sysdeps/mach/hurd/lseek.c: Include . * sysdeps/mach/hurd/lseek.c (__libc_lseek): Check that the value returned by __lseek64 can fit off_t, return EOVERFLOW otherwise. --- diff --git a/ChangeLog b/ChangeLog index 74c14d4f84c..0a2e082d731 100644 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,9 @@ of sendfile. * sysdeps/mach/hurd/sendfile64.c (sendfile64): Rename to __sendfile64. (sendfile64): New strong alias. + * sysdeps/mach/hurd/lseek.c: Include . + * sysdeps/mach/hurd/lseek.c (__libc_lseek): Check that the value + returned by __lseek64 can fit off_t, return EOVERFLOW otherwise. 2018-06-15 Joseph Myers diff --git a/sysdeps/mach/hurd/lseek.c b/sysdeps/mach/hurd/lseek.c index 6677e012023..0a4077268ad 100644 --- a/sysdeps/mach/hurd/lseek.c +++ b/sysdeps/mach/hurd/lseek.c @@ -17,12 +17,22 @@ #include #include +#include /* 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)