diff options
author | Neal Norwitz <nnorwitz@gmail.com> | 2002-09-05 21:48:07 (GMT) |
---|---|---|
committer | Neal Norwitz <nnorwitz@gmail.com> | 2002-09-05 21:48:07 (GMT) |
commit | b567392bbf3c595a47b86ea4d6038af0ec28b383 (patch) | |
tree | d339de20d02348c0dbe03e0d40869997ddc505c0 /Lib/test | |
parent | 7165af23e67d81607ee6dd3191a79001e7a8a4e0 (diff) | |
download | cpython-b567392bbf3c595a47b86ea4d6038af0ec28b383.zip cpython-b567392bbf3c595a47b86ea4d6038af0ec28b383.tar.gz cpython-b567392bbf3c595a47b86ea4d6038af0ec28b383.tar.bz2 |
SF bug # 585792, Invalid mmap crashes Python interpreter
Raise ValueError if user passes a size to mmap which is larger
than the file.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/output/test_mmap | 1 | ||||
-rw-r--r-- | Lib/test/test_mmap.py | 15 |
2 files changed, 16 insertions, 0 deletions
diff --git a/Lib/test/output/test_mmap b/Lib/test/output/test_mmap index 4adf702..1706ad5 100644 --- a/Lib/test/output/test_mmap +++ b/Lib/test/output/test_mmap @@ -24,6 +24,7 @@ test_mmap Ensuring that readonly mmap can't be write() to. Ensuring that readonly mmap can't be write_byte() to. Ensuring that readonly mmap can't be resized. + Opening mmap with size too big Opening mmap with access=ACCESS_WRITE Modifying write-through memory map. Opening mmap with access=ACCESS_COPY diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 11edbaf..dd1fb3f 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -189,6 +189,21 @@ def test_both(): verify(open(TESTFN, "rb").read() == 'a'*mapsize, "Readonly memory map data file was modified") + print " Opening mmap with size too big" + import sys + f = open(TESTFN, "r+b") + try: + m = mmap.mmap(f.fileno(), mapsize+1) + except ValueError: + # we do not expect a ValueError on Windows + if sys.platform.startswith('win'): + verify(0, "Opening mmap with size+1 should work on Windows.") + pass + else: + # we expect a ValueError on Unix, but not on Windows + if not sys.platform.startswith('win'): + verify(0, "Opening mmap with size+1 should raise ValueError.") + print " Opening mmap with access=ACCESS_WRITE" f = open(TESTFN, "r+b") m = mmap.mmap(f.fileno(), mapsize, access=mmap.ACCESS_WRITE) |