This is the mail archive of the
newlib@sourceware.org
mailing list for the newlib project.
[patch] SPU mmap_ea fix
- From: Ken Werner <ken at linux dot vnet dot ibm dot com>
- To: newlib at sourceware dot org
- Date: Fri, 3 Apr 2009 15:00:23 +0200
- Subject: [patch] SPU mmap_ea fix
Hi,
This patch checks the length argument of the mmap_ea function to prevent the
user from mapping more than 4GiB.
Ken
newlib/ChangeLog:
2009-04-03 Ken Werner <ken.werner@de.ibm.com>
* libc/machine/spu/mmap_ea.c (mmap_ea): Check length argument.
Index: src/newlib/libc/machine/spu/mmap_ea.c
===================================================================
--- src.orig/newlib/libc/machine/spu/mmap_ea.c
+++ src/newlib/libc/machine/spu/mmap_ea.c
@@ -41,8 +41,13 @@ __ea void *mmap_ea (__ea void *start, si
flags, int fd, off_t offset)
{
#ifdef __EA64__
- return (__ea void *) mmap_eaddr ((unsigned long long) start, length,
- prot, flags, fd, offset);
+ if (length > 0xffffffffULL) {
+ errno = ENOMEM;
+ return MAP_FAILED_EADDR;
+ } else {
+ return (__ea void *) mmap_eaddr ((unsigned long long) start,
+ (size_t) length, prot, flags, fd, offset);
+ }
#else /* __EA32__ */
unsigned long long res;
/*