mirror of
https://github.com/python/cpython.git
synced 2025-08-15 22:30:42 +00:00
bpo-38256: Fix binascii.crc32 large input. (GH-32000) (GH-32013) (GH-32015)
Inputs >= 4GiB to `binascii.crc32(...)` when compiled to use the zlib
crc32 implementation (the norm on POSIX) no longer return the wrong
result.
(cherry picked from commit 4c989e19c8
)
This commit is contained in:
parent
4aa8b80251
commit
58a7e13037
3 changed files with 27 additions and 8 deletions
|
@ -5,6 +5,8 @@ import binascii
|
|||
import array
|
||||
import re
|
||||
from test import support
|
||||
from test.support import bigmemtest, _1G, _4G, warnings_helper
|
||||
|
||||
|
||||
# Note: "*_hex" functions are aliases for "(un)hexlify"
|
||||
b2a_functions = ['b2a_base64', 'b2a_hex', 'b2a_hqx', 'b2a_qp', 'b2a_uu',
|
||||
|
@ -448,6 +450,14 @@ class BytearrayBinASCIITest(BinASCIITest):
|
|||
class MemoryviewBinASCIITest(BinASCIITest):
|
||||
type2test = memoryview
|
||||
|
||||
class ChecksumBigBufferTestCase(unittest.TestCase):
|
||||
"""bpo-38256 - check that inputs >=4 GiB are handled correctly."""
|
||||
|
||||
@bigmemtest(size=_4G + 4, memuse=1, dry_run=False)
|
||||
def test_big_buffer(self, size):
|
||||
data = b"nyan" * (_1G + 1)
|
||||
self.assertEqual(binascii.crc32(data), 1044521549)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue