diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-19 10:41:45 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2013-01-19 10:41:45 (GMT) |
commit | 9101e23ff6006d9ede7d46e8c9e7d39e23c2a3c3 (patch) | |
tree | c61aebdba4dddc8f10c9460ca33b0fa3f2e1495d /Modules/_io | |
parent | bd8f29028eab752e8e5c73703218a701028c1a9a (diff) | |
parent | 441d30fac7f4037e4a79e4ada873de3b6f6e5a26 (diff) | |
download | cpython-9101e23ff6006d9ede7d46e8c9e7d39e23c2a3c3.zip cpython-9101e23ff6006d9ede7d46e8c9e7d39e23c2a3c3.tar.gz cpython-9101e23ff6006d9ede7d46e8c9e7d39e23c2a3c3.tar.bz2 |
Issue #15989: Fix several occurrences of integer overflow
when result of PyLong_AsLong() narrowed to int without checks.
This is a backport of changesets 13e2e44db99d and 525407d89277.
Diffstat (limited to 'Modules/_io')
-rw-r--r-- | Modules/_io/fileio.c | 4 | ||||
-rw-r--r-- | Modules/_io/textio.c | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/Modules/_io/fileio.c b/Modules/_io/fileio.c index ca25209..8c1fabe 100644 --- a/Modules/_io/fileio.c +++ b/Modules/_io/fileio.c @@ -244,7 +244,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) return -1; } - fd = PyLong_AsLong(nameobj); + fd = _PyLong_AsInt(nameobj); if (fd < 0) { if (!PyErr_Occurred()) { PyErr_SetString(PyExc_ValueError, @@ -382,7 +382,7 @@ fileio_init(PyObject *oself, PyObject *args, PyObject *kwds) goto error; } - self->fd = PyLong_AsLong(fdobj); + self->fd = _PyLong_AsInt(fdobj); Py_DECREF(fdobj); if (self->fd == -1) { goto error; diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c index 83437d6..a93049f 100644 --- a/Modules/_io/textio.c +++ b/Modules/_io/textio.c @@ -881,7 +881,7 @@ textiowrapper_init(textio *self, PyObject *args, PyObject *kwds) } } else { - int fd = (int) PyLong_AsLong(fileno); + int fd = _PyLong_AsInt(fileno); Py_DECREF(fileno); if (fd == -1 && PyErr_Occurred()) { goto error; |