summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2012-04-26 09:24:38 +0200
committerBernhard Reutner-Fischer <rep.dot.nop@gmail.com>2012-04-26 09:24:38 +0200
commitb713a0b26f59e059ba2c73ab802fb03a4e785c03 (patch)
tree30b0dbd21feaf1ca5eb759d00311440fced53b3b /libc/sysdeps/linux/common
parentaa3d9c9202f81d9dabebc232ffa315f12747ced0 (diff)
mmap64: Use correct type for offset parameter
Some arches check the size in INLINE_SYSCALL() and barf if it's too big (i.e. a 64bit value getting truncated to 32bit). Satisfy error-check on ppc32. Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Diffstat (limited to 'libc/sysdeps/linux/common')
-rw-r--r--libc/sysdeps/linux/common/mmap64.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/libc/sysdeps/linux/common/mmap64.c b/libc/sysdeps/linux/common/mmap64.c
index 1c8854a4d..b6eb2b3d0 100644
--- a/libc/sysdeps/linux/common/mmap64.c
+++ b/libc/sysdeps/linux/common/mmap64.c
@@ -50,6 +50,16 @@ __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t
__ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t offset)
{
+ /*
+ * Some arches check the size in INLINE_SYSCALL() and barf if it's
+ * too big (i.e. a 64bit value getting truncated to 32bit).
+ */
+# if __WORDSIZE == 32
+ uint32_t sysoff;
+# else
+ uint64_t sysoff;
+# endif
+
if (offset & ((1 << MMAP2_PAGE_SHIFT) - 1)) {
__set_errno(EINVAL);
return MAP_FAILED;
@@ -61,8 +71,9 @@ __ptr_t mmap64(__ptr_t addr, size_t len, int prot, int flags, int fd, __off64_t
* sign extend things and pass in the wrong value. So cast it to
* an unsigned 64-bit value before doing the shift.
*/
- return (__ptr_t) INLINE_SYSCALL(mmap2, 6, addr, len, prot, flags, fd,
- ((uint64_t)offset >> MMAP2_PAGE_SHIFT));
+ sysoff = (uint64_t)offset >> MMAP2_PAGE_SHIFT;
+
+ return (__ptr_t) INLINE_SYSCALL(mmap2, 6, addr, len, prot, flags, fd, sysoff);
}
# endif