This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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;
   /*

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]