mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #8650: zlib.compress() and zlib.decompress() raise an OverflowError if
the input buffer length doesn't fit into an unsigned int (length bigger than 2^32-1 bytes).
This commit is contained in:
parent
b3c9e073fc
commit
8848c7a37f
3 changed files with 33 additions and 5 deletions
|
@ -2,7 +2,7 @@ import unittest
|
|||
from test import support
|
||||
import binascii
|
||||
import random
|
||||
from test.support import precisionbigmemtest, _1G
|
||||
from test.support import precisionbigmemtest, _1G, _4G
|
||||
|
||||
zlib = support.import_module('zlib')
|
||||
|
||||
|
@ -158,6 +158,16 @@ class CompressTestCase(BaseCompressTestCase, unittest.TestCase):
|
|||
def test_big_decompress_buffer(self, size):
|
||||
self.check_big_decompress_buffer(size, zlib.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)
|
||||
finally:
|
||||
data = None
|
||||
|
||||
|
||||
class CompressObjectTestCase(BaseCompressTestCase, unittest.TestCase):
|
||||
# Test compression object
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue