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
833a3b0d
Commit
833a3b0d
authored
Jul 05, 2017
by
Yury Selivanov
Committed by
GitHub
Jul 05, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bpo-30828: Fix out of bounds write in `asyncio.CFuture.remove_done_callback() (#2569)
parent
8207c174
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
34 additions
and
4 deletions
+34
-4
Lib/test/test_asyncio/test_futures.py
Lib/test/test_asyncio/test_futures.py
+23
-1
Misc/NEWS.d/next/Library/2017-07-04-13-10-52.bpo-30828.CLvEvV.rst
...S.d/next/Library/2017-07-04-13-10-52.bpo-30828.CLvEvV.rst
+1
-0
Modules/_asynciomodule.c
Modules/_asynciomodule.c
+10
-3
No files found.
Lib/test/test_asyncio/test_futures.py
View file @
833a3b0d
...
...
@@ -593,7 +593,7 @@ class BaseFutureDoneCallbackTests():
fut
.
remove_done_callback
(
evil
())
def
test_schedule_callbacks_list_mutation
(
self
):
def
test_schedule_callbacks_list_mutation
_1
(
self
):
# see http://bugs.python.org/issue28963 for details
def
mut
(
f
):
...
...
@@ -606,6 +606,28 @@ class BaseFutureDoneCallbackTests():
fut
.
set_result
(
1
)
test_utils
.
run_briefly
(
self
.
loop
)
def
test_schedule_callbacks_list_mutation_2
(
self
):
# see http://bugs.python.org/issue30828 for details
fut
=
self
.
_new_future
()
fut
.
add_done_callback
(
str
)
for
_
in
range
(
63
):
fut
.
add_done_callback
(
id
)
max_extra_cbs
=
100
extra_cbs
=
0
class
evil
:
def
__eq__
(
self
,
other
):
nonlocal
extra_cbs
extra_cbs
+=
1
if
extra_cbs
<
max_extra_cbs
:
fut
.
add_done_callback
(
id
)
return
False
fut
.
remove_done_callback
(
evil
())
@
unittest
.
skipUnless
(
hasattr
(
futures
,
'_CFuture'
),
'requires the C _asyncio module'
)
...
...
Misc/NEWS.d/next/Library/2017-07-04-13-10-52.bpo-30828.CLvEvV.rst
0 → 100644
View file @
833a3b0d
Fix out of bounds write in `asyncio.CFuture.remove_done_callback()`.
Modules/_asynciomodule.c
View file @
833a3b0d
...
...
@@ -532,9 +532,16 @@ _asyncio_Future_remove_done_callback(FutureObj *self, PyObject *fn)
goto
fail
;
}
if
(
ret
==
0
)
{
Py_INCREF
(
item
);
PyList_SET_ITEM
(
newlist
,
j
,
item
);
j
++
;
if
(
j
<
len
)
{
Py_INCREF
(
item
);
PyList_SET_ITEM
(
newlist
,
j
,
item
);
j
++
;
}
else
{
if
(
PyList_Append
(
newlist
,
item
))
{
goto
fail
;
}
}
}
}
...
...
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