diff options
author | Nadeem Vawda <nadeem.vawda@gmail.com> | 2011-05-14 22:19:50 (GMT) |
---|---|---|
committer | Nadeem Vawda <nadeem.vawda@gmail.com> | 2011-05-14 22:19:50 (GMT) |
commit | 0c3d96ae1dccc081fbc2a8c50ba6e41fbdc384de (patch) | |
tree | fa2ae7dc67ef7fcc9d56e29929ba1472a1333c69 /Lib/test/test_zlib.py | |
parent | 84aacf89125aa46b361a4eb3e3446db4c61eade0 (diff) | |
download | cpython-0c3d96ae1dccc081fbc2a8c50ba6e41fbdc384de.zip cpython-0c3d96ae1dccc081fbc2a8c50ba6e41fbdc384de.tar.gz cpython-0c3d96ae1dccc081fbc2a8c50ba6e41fbdc384de.tar.bz2 |
Issue #8650: Make zlib.[de]compressobj().[de]compress() 64-bit clean.
Raise an OverflowError if the input data is too large, instead of silently
truncating the input and returning an incorrect result.
Diffstat (limited to 'Lib/test/test_zlib.py')
-rw-r--r-- | Lib/test/test_zlib.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/Lib/test/test_zlib.py b/Lib/test/test_zlib.py index 6bc386ed..0909aa1 100644 --- a/Lib/test/test_zlib.py +++ b/Lib/test/test_zlib.py @@ -523,6 +523,17 @@ class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase): decompress = lambda s: d.decompress(s) + d.flush() self.check_big_decompress_buffer(size, decompress) + @precisionbigmemtest(size=_4G + 100, memuse=1) + def test_length_overflow(self, size): + if size < _4G + 100: + self.skipTest("not enough free memory, need at least 4 GB") + data = b'x' * size + try: + self.assertRaises(OverflowError, zlib.compress, data, 1) + self.assertRaises(OverflowError, zlib.decompress, data) + finally: + data = None + def genblock(seed, length, step=1024, generator=random): """length-byte stream of random data from a seed (in step-byte blocks).""" |