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
1a85073d
Commit
1a85073d
authored
Jul 18, 2016
by
Martin Panter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issue #27507: Check for integer overflow in bytearray.extend()
Patch by Xiang Zhang.
parent
fa3fdee1
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
Misc/NEWS
Misc/NEWS
+3
-0
Objects/bytearrayobject.c
Objects/bytearrayobject.c
+11
-1
No files found.
Misc/NEWS
View file @
1a85073d
...
...
@@ -22,6 +22,9 @@ Core and Builtins
- Issue #27473: Fixed possible integer overflow in bytes and bytearray
concatenations. Patch by Xiang Zhang.
- Issue #27507: Add integer overflow check in bytearray.extend(). Patch by
Xiang Zhang.
- Issue #27443: __length_hint__() of bytearray iterators no longer return a
negative integer for a resized bytearray.
...
...
Objects/bytearrayobject.c
View file @
1a85073d
...
...
@@ -2474,7 +2474,17 @@ bytearray_extend(PyByteArrayObject *self, PyObject *iterable_of_ints)
Py_DECREF
(
item
);
if
(
len
>=
buf_size
)
{
buf_size
=
len
+
(
len
>>
1
)
+
1
;
Py_ssize_t
addition
;
if
(
len
==
PY_SSIZE_T_MAX
)
{
Py_DECREF
(
it
);
Py_DECREF
(
bytearray_obj
);
return
PyErr_NoMemory
();
}
addition
=
len
>>
1
;
if
(
addition
>
PY_SSIZE_T_MAX
-
len
-
1
)
buf_size
=
PY_SSIZE_T_MAX
;
else
buf_size
=
len
+
addition
+
1
;
if
(
PyByteArray_Resize
((
PyObject
*
)
bytearray_obj
,
buf_size
)
<
0
)
{
Py_DECREF
(
it
);
Py_DECREF
(
bytearray_obj
);
...
...
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