Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
1d3acd4b
Commit
1d3acd4b
authored
Jan 21, 2013
by
Serhiy Storchaka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #16335: Fix integer overflow in unicode-escape decoder.
parent
b357db88
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
1 deletion
+18
-1
Lib/test/test_ucn.py
Lib/test/test_ucn.py
+16
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+2
-1
No files found.
Lib/test/test_ucn.py
View file @
1d3acd4b
...
...
@@ -8,6 +8,7 @@ Modified for Python 2.0 by Fredrik Lundh (fredrik@pythonware.com)
"""
#"
import
unittest
import
_testcapi
from
test
import
test_support
...
...
@@ -137,6 +138,21 @@ class UnicodeNamesTest(unittest.TestCase):
unicode
,
"
\
\
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'
*
int
(
_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
():
test_support
.
run_unittest
(
UnicodeNamesTest
)
...
...
Objects/unicodeobject.c
View file @
1d3acd4b
...
...
@@ -2899,7 +2899,8 @@ PyObject *PyUnicode_DecodeUnicodeEscape(const char *s,
/* found a name. look it up in the unicode database */
message
=
"unknown Unicode character name"
;
s
++
;
if
(
ucnhash_CAPI
->
getcode
(
NULL
,
start
,
(
int
)(
s
-
start
-
1
),
&
chr
))
if
(
s
-
start
-
1
<=
INT_MAX
&&
ucnhash_CAPI
->
getcode
(
NULL
,
start
,
(
int
)(
s
-
start
-
1
),
&
chr
))
goto
store
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment