Skip to content

ext/ftp: apply the connect timeout ceiling to the remaining entry points - #174

Closed
iliaal wants to merge 1 commit into
PHP-8.4from
ftp-ss001-ssl-timeout-cap
Closed

ext/ftp: apply the connect timeout ceiling to the remaining entry points#174
iliaal wants to merge 1 commit into
PHP-8.4from
ftp-ss001-ssl-timeout-cap

Conversation

@iliaal

@iliaal iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Owner

phpGH-20601 capped the timeout in ftp_connect() so a value that overflows the timeval conversion cannot reach php_network_set_limit_time(). ftp_ssl_connect() and ftp_set_option(FTP_TIMEOUT_SEC) kept rejecting only non-positive values, so PHP_INT_MAX still reached ftp_open() and my_poll() through them. Both now apply the same bound.

The three entry points before this change:

ftp_connect('127.0.0.1', 1024, PHP_INT_MAX);              // ValueError
ftp_ssl_connect('127.0.0.1', 1024, PHP_INT_MAX);          // hangs
ftp_set_option($c, FTP_TIMEOUT_SEC, PHP_INT_MAX);         // bool(true)

Floor PHP-8.4, matching where phpGH-20601 landed.

@iliaal
iliaal force-pushed the ftp-ss001-ssl-timeout-cap branch from 158e19c to 86bba54 Compare July 16, 2026 14:45
@iliaal iliaal changed the title ext/ftp: apply timeout ceiling to ftp_ssl_connect() ext/ftp: apply the connect timeout ceiling to the remaining entry points Jul 16, 2026
@iliaal
iliaal force-pushed the ftp-ss001-ssl-timeout-cap branch 2 times, most recently from 48eccae to 274cbec Compare July 16, 2026 14:58
phpGH-20601 capped the timeout in ftp_connect() so a value that overflows the
timeval conversion cannot reach php_network_set_limit_time(). ftp_ssl_connect()
and ftp_set_option(FTP_TIMEOUT_SEC) kept rejecting only non-positive values, so
PHP_INT_MAX still reached ftp_open() and my_poll() through them.

Apply the same bound to both. ftp_ssl_connect() with PHP_INT_MAX hung before
this rather than reporting the bad argument.

Closes phpGH-22767
@iliaal
iliaal force-pushed the ftp-ss001-ssl-timeout-cap branch from 274cbec to fc3018d Compare July 16, 2026 16:24
@iliaal

iliaal commented Jul 16, 2026

Copy link
Copy Markdown
Owner Author

Promoted upstream: php#22767

@iliaal iliaal closed this Jul 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant