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
487b73ab
Commit
487b73ab
authored
Apr 02, 2019
by
Zackery Spytz
Committed by
Serhiy Storchaka
Apr 02, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-36504: Fix signed integer overflow in _ctypes.c's PyCArrayType_new(). (GH-12660)
parent
b8311cf5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
8 additions
and
1 deletion
+8
-1
Lib/ctypes/test/test_arrays.py
Lib/ctypes/test/test_arrays.py
+6
-0
Misc/NEWS.d/next/Core and Builtins/2019-04-02-04-10-32.bpo-36504.k_V8Bm.rst
...ore and Builtins/2019-04-02-04-10-32.bpo-36504.k_V8Bm.rst
+1
-0
Modules/_ctypes/_ctypes.c
Modules/_ctypes/_ctypes.c
+1
-1
No files found.
Lib/ctypes/test/test_arrays.py
View file @
487b73ab
...
...
@@ -197,6 +197,12 @@ class ArrayTestCase(unittest.TestCase):
_type_
=
c_int
_length_
=
0
def
test_bpo36504_signed_int_overflow
(
self
):
# The overflow check in PyCArrayType_new() could cause signed integer
# overflow.
with
self
.
assertRaises
(
OverflowError
):
c_char
*
sys
.
maxsize
*
2
@
unittest
.
skipUnless
(
sys
.
maxsize
>
2
**
32
,
'requires 64bit platform'
)
@
bigmemtest
(
size
=
_2G
,
memuse
=
1
,
dry_run
=
False
)
def
test_large_array
(
self
,
size
):
...
...
Misc/NEWS.d/next/Core and Builtins/2019-04-02-04-10-32.bpo-36504.k_V8Bm.rst
0 → 100644
View file @
487b73ab
Fix signed integer overflow in _ctypes.c's ``PyCArrayType_new()``.
Modules/_ctypes/_ctypes.c
View file @
487b73ab
...
...
@@ -1518,7 +1518,7 @@ PyCArrayType_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}
itemsize
=
itemdict
->
size
;
if
(
length
*
itemsize
<
0
)
{
if
(
length
>
PY_SSIZE_T_MAX
/
itemsize
)
{
PyErr_SetString
(
PyExc_OverflowError
,
"array too large"
);
goto
error
;
...
...
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