Paranoid integer overflow check in my_mmap
authorReid Barton <rwbarton@gmail.com>
Wed, 28 Aug 2013 21:13:21 +0000 (17:13 -0400)
committerAustin Seipp <aseipp@pobox.com>
Thu, 29 Aug 2013 22:16:51 +0000 (17:16 -0500)
Signed-off-by: Austin Seipp <aseipp@pobox.com>
rts/posix/OSMem.c

index 000ad63..cbc76f8 100644 (file)
@@ -79,6 +79,9 @@ my_mmap (void *addr, W_ size)
 {
     void *ret;
 
+    if (size > (W_)SIZE_MAX)
+        barf("my_mmap: impossibly large allocation of %" FMT_Word " bytes; W_ larger than size_t?", size);
+
 #if defined(solaris2_HOST_OS) || defined(irix_HOST_OS)
     { 
        int fd = open("/dev/zero",O_RDONLY);