summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-09-06 18:25:30 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-09-06 18:25:30 (GMT)
commit56f6e76c680f47ad2b11bed9406305a000a1889a (patch)
tree072b1cbb10bcc6a2f1ddf761c5bf49a8b447a560 /Modules
parent7827a5b7c29ae71daf0175ce3398115374ceb50e (diff)
downloadcpython-56f6e76c680f47ad2b11bed9406305a000a1889a.zip
cpython-56f6e76c680f47ad2b11bed9406305a000a1889a.tar.gz
cpython-56f6e76c680f47ad2b11bed9406305a000a1889a.tar.bz2
Issue #15989: Fixed some scarcely probable integer overflows.
It is very unlikely that they can occur in real code for now.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_datetimemodule.c2
-rw-r--r--Modules/_io/_iomodule.c3
-rw-r--r--Modules/posixmodule.c7
-rw-r--r--Modules/readline.c2
4 files changed, 9 insertions, 5 deletions
diff --git a/Modules/_datetimemodule.c b/Modules/_datetimemodule.c
index 008b733..fe9a948 100644
--- a/Modules/_datetimemodule.c
+++ b/Modules/_datetimemodule.c
@@ -4692,7 +4692,7 @@ local_timezone(PyDateTime_DateTime *utc_time)
if (seconds == NULL)
goto error;
Py_DECREF(delta);
- timestamp = PyLong_AsLong(seconds);
+ timestamp = _PyLong_AsTime_t(seconds);
Py_DECREF(seconds);
if (timestamp == -1 && PyErr_Occurred())
return NULL;
diff --git a/Modules/_io/_iomodule.c b/Modules/_io/_iomodule.c
index 1c2d3a0..7428aed 100644
--- a/Modules/_io/_iomodule.c
+++ b/Modules/_io/_iomodule.c
@@ -238,7 +238,8 @@ _io_open_impl(PyModuleDef *module, PyObject *file, const char *mode,
int text = 0, binary = 0, universal = 0;
char rawmode[6], *m;
- int line_buffering, isatty;
+ int line_buffering;
+ long isatty;
PyObject *raw, *modeobj = NULL, *buffer, *wrapper, *result = NULL;
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index d2b8dfd..270de0f 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -9481,7 +9481,7 @@ os__getdiskusage_impl(PyModuleDef *module, Py_UNICODE *path)
*/
struct constdef {
char *name;
- long value;
+ int value;
};
static int
@@ -9489,7 +9489,10 @@ conv_confname(PyObject *arg, int *valuep, struct constdef *table,
size_t tablesize)
{
if (PyLong_Check(arg)) {
- *valuep = PyLong_AS_LONG(arg);
+ int value = _PyLong_AsInt(arg);
+ if (value == -1 && PyErr_Occurred())
+ return 0;
+ *valuep = value;
return 1;
}
else {
diff --git a/Modules/readline.c b/Modules/readline.c
index f6b52a0..09877f2 100644
--- a/Modules/readline.c
+++ b/Modules/readline.c
@@ -840,7 +840,7 @@ on_hook(PyObject *func)
if (r == Py_None)
result = 0;
else {
- result = PyLong_AsLong(r);
+ result = _PyLong_AsInt(r);
if (result == -1 && PyErr_Occurred())
goto error;
}