Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
Closed
Description
Ifpid_t has the same size asint,PyLong_AsPid is defined asPyLong_AsLong. if the size ofint is less than the size oflong, there are values out of the Cint range but in the Clong range. CallingPyLong_AsPid() with such argument will not raise an exception, but casting the result out of the Cint range topid_t has undefined behavior.
Most non-Windows 64-bit platforms are affected.
The simplest solution is to definePyLong_AsPid asPyLong_AsInt. It only applicable in 3.13, becausePyLong_AsInt is new in 3.13. In older versions there is_PyLong_AsInt, but it is declared inInclude/cpython/longobject.h, not inInclude/longobject.h.
Linked PRs
- gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms #117064
- [3.12] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) #117070
- [3.11] gh-117021: Fix integer overflow in PyLong_AsPid() on non-Windows 64-bit platforms (GH-117064) (GH-117070) #117075