-
-
Notifications
You must be signed in to change notification settings - Fork 32.3k
gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms #117064
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Fix integer overflow in :c:func:`PyLong_AsPid` on non-Windows 64-bit | ||
platforms. |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -746,6 +746,17 @@ pylong_asvoidptr(PyObject *module, PyObject *arg) | |
return Py_NewRef((PyObject *)value); | ||
} | ||
|
||
static PyObject * | ||
pylong_aspid(PyObject *module, PyObject *arg) | ||
{ | ||
NULLABLE(arg); | ||
pid_t value = PyLong_AsPid(arg); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line is built with I propose to merge the PR like that but consider later to find a way to test multiple versions of the limited C API. IMO we need at least separated .c files in There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that it would be better to define |
||
if (value == -1 && PyErr_Occurred()) { | ||
return NULL; | ||
} | ||
return PyLong_FromPid(value); | ||
} | ||
|
||
|
||
static PyMethodDef test_methods[] = { | ||
_TESTLIMITEDCAPI_TEST_LONG_AND_OVERFLOW_METHODDEF | ||
|
@@ -773,6 +784,7 @@ static PyMethodDef test_methods[] = { | |
{"pylong_as_size_t", pylong_as_size_t, METH_O}, | ||
{"pylong_asdouble", pylong_asdouble, METH_O}, | ||
{"pylong_asvoidptr", pylong_asvoidptr, METH_O}, | ||
{"pylong_aspid", pylong_aspid, METH_O}, | ||
{NULL}, | ||
}; | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, that's very interesting, testing two implementations thanks to the new
_testlimitedcapi
extension! That's cool!