summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2015-03-31 14:31:19 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2015-03-31 14:31:19 (GMT)
commit1bb0aef4d1e0e9c61056d190716f08aa26dd3c38 (patch)
tree0d78e9b9df6d36493326e11a178aa90949ef6b7b /Modules
parente50e7802340f07b57cd230fe7e71e92a2a37cf65 (diff)
downloadcpython-1bb0aef4d1e0e9c61056d190716f08aa26dd3c38.zip
cpython-1bb0aef4d1e0e9c61056d190716f08aa26dd3c38.tar.gz
cpython-1bb0aef4d1e0e9c61056d190716f08aa26dd3c38.tar.bz2
Issue #22117: Fix integer overflow check in socket_parse_timeout() on Windows
Diffstat (limited to 'Modules')
-rw-r--r--Modules/socketmodule.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 2eea726..a33c127 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -2197,6 +2197,9 @@ socket_parse_timeout(_PyTime_t *timeout, PyObject *timeout_obj)
#ifdef MS_WINDOWS
struct timeval tv;
#endif
+#ifndef HAVE_POLL
+ _PyTime_t ms;
+#endif
int overflow = 0;
if (timeout_obj == Py_None) {
@@ -2214,11 +2217,11 @@ socket_parse_timeout(_PyTime_t *timeout, PyObject *timeout_obj)
}
#ifdef MS_WINDOWS
- overflow = (_PyTime_AsTimeval(timeout, &tv, _PyTime_ROUND_CEILING) < 0);
+ overflow |= (_PyTime_AsTimeval(*timeout, &tv, _PyTime_ROUND_CEILING) < 0);
#endif
#ifndef HAVE_POLL
- timeout = _PyTime_AsMilliseconds(timeout, _PyTime_ROUND_CEILING);
- overflow = (timeout > INT_MAX);
+ ms = _PyTime_AsMilliseconds(*timeout, _PyTime_ROUND_CEILING);
+ overflow |= (ms > INT_MAX);
#endif
if (overflow) {
PyErr_SetString(PyExc_OverflowError,