diff options
| author | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-03-31 13:13:05 (GMT) |
|---|---|---|
| committer | Hirokazu Yamamoto <ocean-city@m2.ccsnet.ne.jp> | 2009-03-31 13:13:05 (GMT) |
| commit | 9d2ee5ded2ffd7e533776936ac3b34dbb782a847 (patch) | |
| tree | 7ca4669f2c152d2be0f7f2811d702f67e443b299 /Lib/test/test_mmap.py | |
| parent | b2898e0acb7c40c8e77f0210d564eefa4779f24a (diff) | |
| download | cpython-9d2ee5ded2ffd7e533776936ac3b34dbb782a847.zip cpython-9d2ee5ded2ffd7e533776936ac3b34dbb782a847.tar.gz cpython-9d2ee5ded2ffd7e533776936ac3b34dbb782a847.tar.bz2 | |
Issue #5387: Fixed mmap.move crash by integer overflow.
Diffstat (limited to 'Lib/test/test_mmap.py')
| -rw-r--r-- | Lib/test/test_mmap.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/Lib/test/test_mmap.py b/Lib/test/test_mmap.py index 2dd76ad..b8998ea 100644 --- a/Lib/test/test_mmap.py +++ b/Lib/test/test_mmap.py @@ -339,6 +339,23 @@ class MmapTests(unittest.TestCase): mf.close() f.close() + # more excessive test + data = "0123456789" + for dest in range(len(data)): + for src in range(len(data)): + for count in range(len(data) - max(dest, src)): + expected = data[:dest] + data[src:src+count] + data[dest+count:] + m = mmap.mmap(-1, len(data)) + m[:] = data + m.move(dest, src, count) + self.assertEqual(m[:], expected) + m.close() + + # should not crash + m = mmap.mmap(-1, 1) + self.assertRaises(ValueError, m.move, 1, 1, -1) + m.close() + def test_anonymous(self): # anonymous mmap.mmap(-1, PAGE) m = mmap.mmap(-1, PAGESIZE) |
