mirror of
https://github.com/python/cpython.git
synced 2025-07-28 05:34:31 +00:00
Fix possible undefined behaviour from signed overflow in struct module.
Backport of revisions 81897, 81898 and 81902 from py3k.
This commit is contained in:
parent
b65bd2e3eb
commit
40228912c8
2 changed files with 35 additions and 22 deletions
|
@ -526,6 +526,12 @@ class StructTest(unittest.TestCase):
|
|||
def test_crasher(self):
|
||||
self.assertRaises(MemoryError, struct.pack, "357913941c", "a")
|
||||
|
||||
def test_count_overflow(self):
|
||||
hugecount = '{}b'.format(sys.maxsize+1)
|
||||
self.assertRaises(struct.error, struct.calcsize, hugecount)
|
||||
|
||||
hugecount2 = '{}b{}H'.format(sys.maxsize//2, sys.maxsize//2)
|
||||
self.assertRaises(struct.error, struct.calcsize, hugecount2)
|
||||
|
||||
def test_main():
|
||||
run_unittest(StructTest)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue