diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-19 12:55:39 +0200 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-19 12:55:39 +0200 |
commit | 74f49ab28b91d3c23524356230feb2724ee9b23f (patch) | |
tree | 0ddd5e8899d06c974dfc25a7dfc298e3f6f70039 /Objects/fileobject.c | |
parent | ac7b49f4076a4336915d13a4aa19feaeadd29d62 (diff) | |
download | cpython-git-74f49ab28b91d3c23524356230feb2724ee9b23f.tar.gz |
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.
Diffstat (limited to 'Objects/fileobject.c')
-rw-r--r-- | Objects/fileobject.c | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c index ece23703d4..76cdf74777 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -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 { |