]> granicus.if.org Git - python/commitdiff
Issue #22117: Fix integer overflow check in socket_parse_timeout() on Windows
authorVictor Stinner <victor.stinner@gmail.com>
Tue, 31 Mar 2015 14:31:19 +0000 (16:31 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Tue, 31 Mar 2015 14:31:19 +0000 (16:31 +0200)
Modules/socketmodule.c

index 2eea726081d9b968512c4e40adeb574aea051457..a33c12740c1843714de7893baeac4d1c7221cf4a 100644 (file)
@@ -2196,6 +2196,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;
 
@@ -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,