mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
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.
This commit is contained in:
parent
84aacf8912
commit
0c3d96ae1d
3 changed files with 39 additions and 14 deletions
|
|
@ -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)."""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue