Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-33191: Fix refleak in posix_spawn#6315

Closed
zware wants to merge 3 commits into
python:masterpython/cpython:masterfrom
zware:fix_refleakzware/cpython:fix_refleakCopy head branch name to clipboard
Closed

bpo-33191: Fix refleak in posix_spawn#6315
zware wants to merge 3 commits into
python:masterpython/cpython:masterfrom
zware:fix_refleakzware/cpython:fix_refleakCopy head branch name to clipboard

Conversation

@zware

@zware zware commented Mar 30, 2018

Copy link
Copy Markdown
Member

@serhiy-storchaka serhiy-storchaka self-requested a review March 31, 2018 07:39
Comment thread Modules/posixmodule.c

if(!PySequence_Check(file_actions_obj) | !PySequence_Size(file_actions_obj)) {
PyErr_SetString(PyExc_TypeError,"Each file_action element must be a non empty sequence");
if (file_actions_obj == NULL) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible?

Comment thread Modules/posixmodule.c
if (file_actions_obj == NULL) {
goto exit;
}
file_actions_obj = PySequence_Fast(file_actions_obj, "Each file_action element must be a non-empty sequence");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would be nice to wrap this long line.

Comment thread Modules/posixmodule.c

long open_fd = PyLong_AsLong(PySequence_GetItem(file_actions_obj, 1));
long open_fd = PyLong_AsLong(PySequence_Fast_GET_ITEM(file_actions_obj, 1));
if(PyErr_Occurred()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While you are here, could you please make the source conforming PEP 7: Add spaces after "if" and "switch", wrap long lines?

Comment thread Modules/posixmodule.c
}

long open_fd = PyLong_AsLong(PySequence_GetItem(file_actions_obj, 1));
long open_fd = PyLong_AsLong(PySequence_Fast_GET_ITEM(file_actions_obj, 1));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PyLong_AsLong() can call arbitrary code. If file_actions is a list, the size of file_actions_obj can be changed after this, and the following PySequence_Fast_GET_ITEM() could read past the end of the list.

I would require file_actions to be a tuple and use PyArg_ParseTuple() for parsing it.

@serhiy-storchaka

Copy link
Copy Markdown
Member

I have added more comments in #5109 because it is hard to add comment to the code not changed in a PR.

@zware

zware commented Mar 31, 2018

Copy link
Copy Markdown
Member Author

@serhiy-storchaka Would you mind to take this over? I would like to see this fixed before 3.7.0 final, but don't know when I'll be able to get back to it.

@pablogsal

Copy link
Copy Markdown
Member

I have opened #6331 trying to address al the issues at once.

@gpshead

gpshead commented Apr 1, 2018

Copy link
Copy Markdown
Member

#6332 should obsolete this

@zware

zware commented Apr 2, 2018

Copy link
Copy Markdown
Member Author

Superseded by #6332 and/or #6331.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type-bug An unexpected behavior, bug, or error

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.