mirror of
https://github.com/python/cpython.git
synced 2025-11-01 14:11:41 +00:00
Issue #16335: Fix integer overflow in unicode-escape decoder.
This commit is contained in:
commit
c35f3a9f61
2 changed files with 18 additions and 1 deletions
|
|
@ -9,6 +9,7 @@
|
|||
|
||||
import unittest
|
||||
import unicodedata
|
||||
import _testcapi
|
||||
|
||||
from test import support
|
||||
from http.client import HTTPException
|
||||
|
|
@ -215,6 +216,21 @@ def test_strict_error_handling(self):
|
|||
str, b"\\NSPACE", 'unicode-escape', 'strict'
|
||||
)
|
||||
|
||||
@unittest.skipUnless(_testcapi.INT_MAX < _testcapi.PY_SSIZE_T_MAX,
|
||||
"needs UINT_MAX < SIZE_MAX")
|
||||
def test_issue16335(self):
|
||||
# very very long bogus character name
|
||||
try:
|
||||
x = b'\\N{SPACE' + b'x' * (_testcapi.UINT_MAX + 1) + b'}'
|
||||
except MemoryError:
|
||||
raise unittest.SkipTest("not enough memory")
|
||||
self.assertEqual(len(x), len(b'\\N{SPACE}') + (_testcapi.UINT_MAX + 1))
|
||||
self.assertRaisesRegex(UnicodeError,
|
||||
'unknown Unicode character name',
|
||||
x.decode, 'unicode-escape'
|
||||
)
|
||||
|
||||
|
||||
def test_main():
|
||||
support.run_unittest(UnicodeNamesTest)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue