[commit: ghc] master: Paranoid integer overflow check in my_mmap (1ce65ed)

git at git.haskell.org git at git.haskell.org
Fri Aug 30 00:17:12 CEST 2013


Repository : ssh://git@git.haskell.org/ghc

On branch  : master
Link       : http://ghc.haskell.org/trac/ghc/changeset/1ce65edbff90fc8103062a1f94258ecc0c682309/ghc

>---------------------------------------------------------------

commit 1ce65edbff90fc8103062a1f94258ecc0c682309
Author: Reid Barton <rwbarton at gmail.com>
Date:   Wed Aug 28 17:13:21 2013 -0400

    Paranoid integer overflow check in my_mmap
    
    Signed-off-by: Austin Seipp <aseipp at pobox.com>


>---------------------------------------------------------------

1ce65edbff90fc8103062a1f94258ecc0c682309
 rts/posix/OSMem.c |    3 +++
 1 file changed, 3 insertions(+)

diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 000ad63..cbc76f8 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -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);





More information about the ghc-commits mailing list