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
fd83a823
Commit
fd83a823
authored
Apr 03, 2019
by
Zackery Spytz
Committed by
Serhiy Storchaka
Apr 03, 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) (GH-12678)
(cherry picked from commit
487b73ab
)
parent
a110817c
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 @
fd83a823
...
...
@@ -134,6 +134,12 @@ class ArrayTestCase(unittest.TestCase):
t2
=
my_int
*
1
self
.
assertIs
(
t1
,
t2
)
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'
)
@
precisionbigmemtest
(
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 @
fd83a823
Fix signed integer overflow in _ctypes.c's ``PyCArrayType_new()``.
Modules/_ctypes/_ctypes.c
View file @
fd83a823
...
...
@@ -1534,7 +1534,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"
);
Py_DECREF
(
stgdict
);
...
...
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