1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.5'

* PHP-8.5:
  Fix GH-20240: FTP with SSL: ftp_fput(): Connection timed out on successful writes
This commit is contained in:
Niels Dossche
2025-10-26 23:40:01 +01:00

View File

@@ -1508,7 +1508,7 @@ static int my_recv(ftpbuf_t *ftp, php_socket_t s, void *buf, size_t len)
return (nr_bytes);
}
static bool data_available(ftpbuf_t *ftp, php_socket_t s)
static bool data_available(ftpbuf_t *ftp, php_socket_t s, bool silent)
{
int n;
@@ -1516,6 +1516,9 @@ static bool data_available(ftpbuf_t *ftp, php_socket_t s)
if (n < 1) {
char buf[256];
if (n == 0) {
if (silent) {
return false;
}
#ifdef PHP_WIN32
_set_errno(ETIMEDOUT);
#else
@@ -1831,7 +1834,9 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
done = 0;
}
while (!done && data_available(ftp, fd)) {
/* Don't report timeouts on the control channel if we're negotiating a shutdown already.
* Some servers don't put a final response. */
while (!done && data_available(ftp, fd, true)) {
ERR_clear_error();
nread = SSL_read(ssl_handle, buf, sizeof(buf));
if (nread <= 0) {
@@ -2078,7 +2083,7 @@ int ftp_nb_continue_read(ftpbuf_t *ftp)
data = ftp->data;
/* check if there is already more data */
if (!data_available(ftp, data->fd)) {
if (!data_available(ftp, data->fd, false)) {
return PHP_FTP_MOREDATA;
}