diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c index fb987c82e5cc2..e4c63a957003e 100644 --- a/ext/standard/http_fopen_wrapper.c +++ b/ext/standard/http_fopen_wrapper.c @@ -219,7 +219,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper, #ifndef PHP_WIN32 const double timeoutmax = (double) PHP_TIMEOUT_ULL_MAX / 1000000.0; #else - const double timeoutmax = (double) LONG_MAX / 1000000.0; + const double timeoutmax = (double) LONG_MAX + 0.999999; #endif if (d > timeoutmax) { diff --git a/main/network.c b/main/network.c index d4938a4a08c1e..df42f57358655 100644 --- a/main/network.c +++ b/main/network.c @@ -319,6 +319,14 @@ static inline void php_network_set_limit_time(struct timeval *limit_time, struct timeval *timeout) { gettimeofday(limit_time, NULL); +# ifdef PHP_WIN32 + /* cap timeout (we're not picky regarding usec) */ + if (limit_time->tv_sec > (LONG_MAX - timeout->tv_sec) + 1) { + limit_time->tv_sec = LONG_MAX; + limit_time->tv_usec = 999999; + return; + } +# endif limit_time->tv_sec += timeout->tv_sec; limit_time->tv_usec += timeout->tv_usec; if (limit_time->tv_usec >= 1000000) {