summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
authorMark Dickinson <dickinsm@gmail.com>2010-06-12 08:49:42 (GMT)
committerMark Dickinson <dickinsm@gmail.com>2010-06-12 08:49:42 (GMT)
commit38b4a898fd4c624bde2e401ecdc28888ec41e6de (patch)
treec3171ca716fa6a62b10da2eafecba6ca88cc4666 /Lib
parent4f6ebc2db814a363bfd5b6445225ab93e17adb3e (diff)
downloadcpython-38b4a898fd4c624bde2e401ecdc28888ec41e6de.zip
cpython-38b4a898fd4c624bde2e401ecdc28888ec41e6de.tar.gz
cpython-38b4a898fd4c624bde2e401ecdc28888ec41e6de.tar.bz2
Merged revisions 81904 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r81904 | mark.dickinson | 2010-06-11 21:27:05 +0100 (Fri, 11 Jun 2010) | 4 lines Fix possible undefined behaviour from signed overflow in struct module. Backport of revisions 81897, 81898 and 81902 from py3k. ........
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_struct.py6
1 files changed, 5 insertions, 1 deletions
diff --git a/Lib/test/test_struct.py b/Lib/test/test_struct.py
index ad754df..c010492 100644
--- a/Lib/test/test_struct.py
+++ b/Lib/test/test_struct.py
@@ -12,7 +12,6 @@ from test.test_support import TestFailed, verbose, run_unittest
import sys
ISBIGENDIAN = sys.byteorder == "big"
IS32BIT = sys.maxsize == 0x7fffffff
-del sys
try:
import _struct
@@ -605,7 +604,12 @@ class StructTest(unittest.TestCase):
def test_crasher(self):
self.assertRaises(MemoryError, struct.pack, "357913941c", "a")
+ def test_count_overflow(self):
+ hugecount = '{0}b'.format(sys.maxsize+1)
+ self.assertRaises(struct.error, struct.calcsize, hugecount)
+ hugecount2 = '{0}b{1}H'.format(sys.maxsize//2, sys.maxsize//2)
+ self.assertRaises(struct.error, struct.calcsize, hugecount2)
def test_main():
run_unittest(StructTest)