Issue #22117: Fix integer overflow check in socket_parse_timeout() on Windows
This commit is contained in:
parent
e50e780234
commit
1bb0aef4d1
|
@ -2196,6 +2196,9 @@ socket_parse_timeout(_PyTime_t *timeout, PyObject *timeout_obj)
|
||||||
{
|
{
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
#endif
|
||||||
|
#ifndef HAVE_POLL
|
||||||
|
_PyTime_t ms;
|
||||||
#endif
|
#endif
|
||||||
int overflow = 0;
|
int overflow = 0;
|
||||||
|
|
||||||
|
@ -2214,11 +2217,11 @@ socket_parse_timeout(_PyTime_t *timeout, PyObject *timeout_obj)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef MS_WINDOWS
|
#ifdef MS_WINDOWS
|
||||||
overflow = (_PyTime_AsTimeval(timeout, &tv, _PyTime_ROUND_CEILING) < 0);
|
overflow |= (_PyTime_AsTimeval(*timeout, &tv, _PyTime_ROUND_CEILING) < 0);
|
||||||
#endif
|
#endif
|
||||||
#ifndef HAVE_POLL
|
#ifndef HAVE_POLL
|
||||||
timeout = _PyTime_AsMilliseconds(timeout, _PyTime_ROUND_CEILING);
|
ms = _PyTime_AsMilliseconds(*timeout, _PyTime_ROUND_CEILING);
|
||||||
overflow = (timeout > INT_MAX);
|
overflow |= (ms > INT_MAX);
|
||||||
#endif
|
#endif
|
||||||
if (overflow) {
|
if (overflow) {
|
||||||
PyErr_SetString(PyExc_OverflowError,
|
PyErr_SetString(PyExc_OverflowError,
|
||||||
|
|
Loading…
Reference in New Issue