diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2010-06-11 20:08:36 (GMT) |
---|---|---|
committer | Mark Dickinson <dickinsm@gmail.com> | 2010-06-11 20:08:36 (GMT) |
commit | 4a3acca7c1f85946ac7526e303956dc03acd91fe (patch) | |
tree | 73d2e0bd87f9f82cb3136f4b72460c6b8ae69429 /Lib/test/test_struct.py | |
parent | 7a61e3c3599cdd1ae72d33f9d4343ee60ffddb61 (diff) | |
download | cpython-4a3acca7c1f85946ac7526e303956dc03acd91fe.zip cpython-4a3acca7c1f85946ac7526e303956dc03acd91fe.tar.gz cpython-4a3acca7c1f85946ac7526e303956dc03acd91fe.tar.bz2 |
Merged revisions 81897-81898,81902 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k
........
r81897 | mark.dickinson | 2010-06-11 17:56:34 +0100 (Fri, 11 Jun 2010) | 1 line
Avoid possible undefined behaviour from signed overflow.
........
r81898 | mark.dickinson | 2010-06-11 20:05:08 +0100 (Fri, 11 Jun 2010) | 1 line
Fix an incorrect return type.
........
r81902 | mark.dickinson | 2010-06-11 20:50:30 +0100 (Fri, 11 Jun 2010) | 1 line
Fix more undefined-behaviour inducing overflow checks in struct module.
........
Diffstat (limited to 'Lib/test/test_struct.py')
-rw-r--r-- | Lib/test/test_struct.py | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py index 684dc6c..6032895 100644 --- a/Lib/test/test_struct.py +++ b/Lib/test/test_struct.py @@ -511,6 +511,13 @@ class StructTest(unittest.TestCase): for c in [b'\x01', b'\x7f', b'\xff', b'\x0f', b'\xf0']: self.assertTrue(struct.unpack('>?', c)[0]) + 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) + if IS32BIT: def test_crasher(self): self.assertRaises(MemoryError, struct.pack, "357913941b", "a") |