mirror of
https://github.com/python/cpython.git
synced 2025-09-26 10:19:53 +00:00
Issue #15989: Fix several occurrences of integer overflow
when result of PyInt_AsLong() or PyLong_AsLong() narrowed to int without checks. This is a backport of changesets 13e2e44db99d and 525407d89277.
This commit is contained in:
parent
ac7b49f407
commit
74f49ab28b
17 changed files with 143 additions and 22 deletions
|
@ -2659,10 +2659,10 @@ int PyObject_AsFileDescriptor(PyObject *o)
|
|||
PyObject *meth;
|
||||
|
||||
if (PyInt_Check(o)) {
|
||||
fd = PyInt_AsLong(o);
|
||||
fd = _PyInt_AsInt(o);
|
||||
}
|
||||
else if (PyLong_Check(o)) {
|
||||
fd = PyLong_AsLong(o);
|
||||
fd = _PyLong_AsInt(o);
|
||||
}
|
||||
else if ((meth = PyObject_GetAttrString(o, "fileno")) != NULL)
|
||||
{
|
||||
|
@ -2672,11 +2672,11 @@ int PyObject_AsFileDescriptor(PyObject *o)
|
|||
return -1;
|
||||
|
||||
if (PyInt_Check(fno)) {
|
||||
fd = PyInt_AsLong(fno);
|
||||
fd = _PyInt_AsInt(fno);
|
||||
Py_DECREF(fno);
|
||||
}
|
||||
else if (PyLong_Check(fno)) {
|
||||
fd = PyLong_AsLong(fno);
|
||||
fd = _PyLong_AsInt(fno);
|
||||
Py_DECREF(fno);
|
||||
}
|
||||
else {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue