Skip to content

Commit 64b30ce

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix phpGH-20240: FTP with SSL: ftp_fput(): Connection timed out on successful writes
2 parents c0214e4 + 6bcc4e2 commit 64b30ce

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

ext/ftp/ftp.c

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1508,14 +1508,17 @@ static int my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
15081508
return (nr_bytes);
15091509
}
15101510

1511-
static bool data_available(ftpbuf_t *ftp, php_socket_t s)
1511+
static bool data_available(ftpbuf_t *ftp, php_socket_t s, bool silent)
15121512
{
15131513
int n;
15141514

15151515
n = my_poll(s, PHP_POLLREADABLE, 1000);
15161516
if (n < 1) {
15171517
char buf[256];
15181518
if (n == 0) {
1519+
if (silent) {
1520+
return false;
1521+
}
15191522
#ifdef PHP_WIN32
15201523
_set_errno(ETIMEDOUT);
15211524
#else
@@ -1831,7 +1834,9 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
18311834
done = 0;
18321835
}
18331836

1834-
while (!done && data_available(ftp, fd)) {
1837+
/* Don't report timeouts on the control channel if we're negotiating a shutdown already.
1838+
* Some servers don't put a final response. */
1839+
while (!done && data_available(ftp, fd, true)) {
18351840
ERR_clear_error();
18361841
nread = SSL_read(ssl_handle, buf, sizeof(buf));
18371842
if (nread <= 0) {
@@ -2078,7 +2083,7 @@ int ftp_nb_continue_read(ftpbuf_t *ftp)
20782083
data = ftp->data;
20792084

20802085
/* check if there is already more data */
2081-
if (!data_available(ftp, data->fd)) {
2086+
if (!data_available(ftp, data->fd, false)) {
20822087
return PHP_FTP_MOREDATA;
20832088
}
20842089

0 commit comments

Comments
 (0)