Skip to content

Conversation

@zware
Copy link
Member

@zware zware commented Mar 30, 2018

@serhiy-storchaka serhiy-storchaka self-requested a review March 31, 2018 07:39

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
Member

Choose a reason for hiding this comment

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

Is it possible?

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
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.


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
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?

}

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
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
Member

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

@zware
Copy link
Member Author

zware commented Mar 31, 2018

@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
Member

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

@gpshead
Copy link
Member

gpshead commented Apr 1, 2018

#6332 should obsolete this

@zware
Copy link
Member Author

zware commented Apr 2, 2018

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