Skip to content

Commit 6dab33a

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix phpGH-20240: FTP with SSL: ftp_fput(): Connection timed out on successful writes
2 parents d403036 + 8761c4e commit 6dab33a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ PHP NEWS
2525
. Fixed bug GH-19974 (fpm_status_export_to_zval segfault for parallel
2626
execution). (Jakub Zelenka, txuna)
2727

28+
- FTP:
29+
. Fixed bug GH-20240 (FTP with SSL: ftp_fput(): Connection timed out on
30+
successful writes). (nielsdos)
31+
2832
- GD:
2933
. Fixed bug GH-20070 (Return type violation in imagefilter when an invalid
3034
filter is provided). (Girgias)

ext/ftp/ftp.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1625,14 +1625,17 @@ my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
16251625

16261626
/* {{{ data_available */
16271627
int
1628-
data_available(ftpbuf_t *ftp, php_socket_t s)
1628+
data_available(ftpbuf_t *ftp, php_socket_t s, bool silent)
16291629
{
16301630
int n;
16311631

16321632
n = my_poll(s, PHP_POLLREADABLE, 1000);
16331633
if (n < 1) {
16341634
char buf[256];
16351635
if (n == 0) {
1636+
if (silent) {
1637+
return 0;
1638+
}
16361639
#ifdef PHP_WIN32
16371640
_set_errno(ETIMEDOUT);
16381641
#else
@@ -1961,7 +1964,9 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
19611964
done = 0;
19621965
}
19631966

1964-
while (!done && data_available(ftp, fd)) {
1967+
/* Don't report timeouts on the control channel if we're negotiating a shutdown already.
1968+
* Some servers don't put a final response. */
1969+
while (!done && data_available(ftp, fd, true)) {
19651970
ERR_clear_error();
19661971
nread = SSL_read(ssl_handle, buf, sizeof(buf));
19671972
if (nread <= 0) {
@@ -2219,7 +2224,7 @@ ftp_nb_continue_read(ftpbuf_t *ftp)
22192224
data = ftp->data;
22202225

22212226
/* check if there is already more data */
2222-
if (!data_available(ftp, data->fd)) {
2227+
if (!data_available(ftp, data->fd, false)) {
22232228
return PHP_FTP_MOREDATA;
22242229
}
22252230

0 commit comments

Comments
 (0)