Skip to content

Commit d9afc2f

Browse files
committed
Fix #77151 ftp_close(): SSL_read on shutdown
Regression introduced in fix for #76972 only display the error message when sslerror or if errno is set (for SSL_ERROR_SYSCALL case)
1 parent 3e78380 commit d9afc2f

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

ext/ftp/ftp.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1770,10 +1770,10 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
17701770
done = 0;
17711771
}
17721772

1773-
while (!done) {
1774-
if (data_available(ftp, fd)) {
1775-
ERR_clear_error();
1776-
nread = SSL_read(ssl_handle, buf, sizeof(buf));
1773+
while (!done && data_available(ftp, fd)) {
1774+
ERR_clear_error();
1775+
nread = SSL_read(ssl_handle, buf, sizeof(buf));
1776+
if (nread <= 0) {
17771777
err = SSL_get_error(ssl_handle, nread);
17781778
switch (err) {
17791779
case SSL_ERROR_NONE: /* this is not an error */
@@ -1791,9 +1791,11 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
17911791
break;
17921792
default:
17931793
if ((sslerror = ERR_get_error())) {
1794-
ERR_error_string_n(sslerror, buf, sizeof(buf));
1794+
ERR_error_string_n(sslerror, buf, sizeof(buf));
1795+
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s", buf);
1796+
} else if (errno) {
1797+
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", strerror(errno), errno);
17951798
}
1796-
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", (sslerror ? buf : strerror(errno)), errno);
17971799
done = 1;
17981800
break;
17991801
}

0 commit comments

Comments
 (0)