Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix GH-17717: Socket maximum timeout of 2147 seconds? #17720

Open
wants to merge 1 commit into
base: PHP-8.3
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/standard/http_fopen_wrapper.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
8 changes: 8 additions & 0 deletions main/network.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
Loading