summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorBenjamin Peterson <benjamin@python.org>2015-02-01 22:53:53 (GMT)
committerBenjamin Peterson <benjamin@python.org>2015-02-01 22:53:53 (GMT)
commite3bfe19358f9d6747676fcdb9af415972d276671 (patch)
tree5af2f199c00afdfc3c1ebc3c9f4fb10dbc2f68c3 /Lib/test
parent4dbc30500218204eace01fa4d429f3087df5376f (diff)
downloadcpython-e3bfe19358f9d6747676fcdb9af415972d276671.zip
cpython-e3bfe19358f9d6747676fcdb9af415972d276671.tar.gz
cpython-e3bfe19358f9d6747676fcdb9af415972d276671.tar.bz2
fix possible overflow in encode_basestring_ascii (closes #23369)
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/test_json/test_encode_basestring_ascii.py9
1 files changed, 8 insertions, 1 deletions
diff --git a/Lib/test/test_json/test_encode_basestring_ascii.py b/Lib/test/test_json/test_encode_basestring_ascii.py
index 480afd6..3c014d3 100644
--- a/Lib/test/test_json/test_encode_basestring_ascii.py
+++ b/Lib/test/test_json/test_encode_basestring_ascii.py
@@ -1,5 +1,6 @@
from collections import OrderedDict
from test.test_json import PyTest, CTest
+from test.support import bigaddrspacetest
CASES = [
@@ -41,4 +42,10 @@ class TestEncodeBasestringAscii:
class TestPyEncodeBasestringAscii(TestEncodeBasestringAscii, PyTest): pass
-class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest): pass
+class TestCEncodeBasestringAscii(TestEncodeBasestringAscii, CTest):
+ @bigaddrspacetest
+ def test_overflow(self):
+ s = "\uffff"*((2**32)//6 + 1)
+ with self.assertRaises(OverflowError):
+ self.json.encoder.encode_basestring_ascii(s)
+