File tree Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Filter options
Expand file tree Collapse file tree 1 file changed +18
-5
lines changed
Original file line number Diff line number Diff line change @@ -1922,14 +1922,27 @@ kqueue_event_init(PyObject *op, PyObject *args, PyObject *kwds)
1922
1922
return -1 ;
1923
1923
}
1924
1924
1925
- if (PyLong_Check (pfd )) {
1926
- self -> e .ident = PyLong_AsSize_t (pfd );
1925
+ if (PyIndex_Check (pfd )) {
1926
+ Py_ssize_t bytes = PyLong_AsNativeBytes (pfd ,
1927
+ & self -> e .ident , sizeof (self -> e .ident ),
1928
+ Py_ASNATIVEBYTES_NATIVE_ENDIAN |
1929
+ Py_ASNATIVEBYTES_ALLOW_INDEX |
1930
+ Py_ASNATIVEBYTES_REJECT_NEGATIVE |
1931
+ Py_ASNATIVEBYTES_UNSIGNED_BUFFER );
1932
+ if (bytes < 0 ) {
1933
+ return -1 ;
1934
+ }
1935
+ if ((size_t )bytes > sizeof (self -> e .ident )) {
1936
+ PyErr_SetString (PyExc_OverflowError ,
1937
+ "Python int too large for C kqueue event identifier" );
1938
+ return -1 ;
1939
+ }
1927
1940
}
1928
1941
else {
1929
1942
self -> e .ident = PyObject_AsFileDescriptor (pfd );
1930
- }
1931
- if ( PyErr_Occurred ()) {
1932
- return -1 ;
1943
+ if ( PyErr_Occurred ()) {
1944
+ return -1 ;
1945
+ }
1933
1946
}
1934
1947
return 0 ;
1935
1948
}
You can’t perform that action at this time.
0 commit comments