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
e1bd38c0
Commit
e1bd38c0
authored
Oct 15, 2014
by
Benjamin Peterson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix integer overflow in unicode case operations (closes #22643)
parent
77a75b3d
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
0 deletions
+13
-0
Lib/test/test_unicode.py
Lib/test/test_unicode.py
+5
-0
Misc/NEWS
Misc/NEWS
+3
-0
Objects/unicodeobject.c
Objects/unicodeobject.c
+5
-0
No files found.
Lib/test/test_unicode.py
View file @
e1bd38c0
...
@@ -661,6 +661,11 @@ class UnicodeTest(string_tests.CommonTest,
...
@@ -661,6 +661,11 @@ class UnicodeTest(string_tests.CommonTest,
self
.
assertEqual
(
'x'
.
center
(
4
,
'
\
U0010FFFF
'
),
self
.
assertEqual
(
'x'
.
center
(
4
,
'
\
U0010FFFF
'
),
'
\
U0010FFFF
x
\
U0010FFFF
\
U0010FFFF
'
)
'
\
U0010FFFF
x
\
U0010FFFF
\
U0010FFFF
'
)
@
unittest
.
skipUnless
(
sys
.
maxsize
==
2
**
31
-
1
,
"requires 32-bit system"
)
def
test_case_operation_overflow
(
self
):
# Issue #22643
self
.
assertRaises
(
OverflowError
,
(
"ü"
*
(
2
**
32
//
12
+
1
)).
upper
)
def
test_contains
(
self
):
def
test_contains
(
self
):
# Testing Unicode contains method
# Testing Unicode contains method
self
.
assertIn
(
'a'
,
'abdb'
)
self
.
assertIn
(
'a'
,
'abdb'
)
...
...
Misc/NEWS
View file @
e1bd38c0
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.6?
...
@@ -10,6 +10,9 @@ What's New in Python 3.3.6?
Core and Builtins
Core and Builtins
-----------------
-----------------
- Issue #22643: Fix integer overflow in Unicode case operations (upper, lower,
title, swapcase, casefold).
- Issue #22518: Fixed integer overflow issues in "backslashreplace",
- Issue #22518: Fixed integer overflow issues in "backslashreplace",
"xmlcharrefreplace", and "surrogatepass" error handlers.
"xmlcharrefreplace", and "surrogatepass" error handlers.
...
...
Objects/unicodeobject.c
View file @
e1bd38c0
...
@@ -9484,6 +9484,11 @@ case_operation(PyObject *self,
...
@@ -9484,6 +9484,11 @@ case_operation(PyObject *self,
kind
=
PyUnicode_KIND
(
self
);
kind
=
PyUnicode_KIND
(
self
);
data
=
PyUnicode_DATA
(
self
);
data
=
PyUnicode_DATA
(
self
);
length
=
PyUnicode_GET_LENGTH
(
self
);
length
=
PyUnicode_GET_LENGTH
(
self
);
if
(
length
>
PY_SSIZE_T_MAX
/
3
||
length
>
PY_SIZE_MAX
/
(
3
*
sizeof
(
Py_UCS4
)))
{
PyErr_SetString
(
PyExc_OverflowError
,
"string is too long"
);
return
NULL
;
}
tmp
=
PyMem_MALLOC
(
sizeof
(
Py_UCS4
)
*
3
*
length
);
tmp
=
PyMem_MALLOC
(
sizeof
(
Py_UCS4
)
*
3
*
length
);
if
(
tmp
==
NULL
)
if
(
tmp
==
NULL
)
return
PyErr_NoMemory
();
return
PyErr_NoMemory
();
...
...
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