Subject: | length wraparound |
Date: | Fri, 16 Apr 2010 08:58:10 +1000 |
To: | bug-File-Map [...] rt.cpan.org |
From: | Kevin Ryde <user42 [...] zip.com.au> |
Nosing around the code of 0.24, I think the "correction" value applied
to the length may cause it to wrap around if close to 2**32. Eg.
map_file (my $str, '/dev/zero', '<', 4095, 2**32-1);
=> success
Some printfs show it calling mmap() with length 4094 at offset 0, where
I expected it might fail due to not having 2**32-1 bytes of address
space on a 32-bit system.
You might throw ENOMEM when length+correction is bigger than 2**32.
That'd be same as when length is huge but doesn't wraparound,
map_file (my $str, '/dev/zero', '<', 0, 2**32-1);
=> Cannot allocate memory