summaryrefslogtreecommitdiff
path: root/ext/ftp
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2018-11-15 08:58:08 +0100
committerRemi Collet <remi@php.net>2018-11-20 11:18:34 +0100
commitd9afc2f662587a042db38c8f0df98a27bfc89d29 (patch)
tree0237da159cf7ea76c72ce31be5262098c4f361cc /ext/ftp
parent3e78380d02085f83c5d50d683670e6b5dd1b1582 (diff)
downloadphp-git-d9afc2f662587a042db38c8f0df98a27bfc89d29.tar.gz
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)
Diffstat (limited to 'ext/ftp')
-rw-r--r--ext/ftp/ftp.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index 88553b969c..44e3bf2510 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -1770,10 +1770,10 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
done = 0;
}
- while (!done) {
- if (data_available(ftp, fd)) {
- ERR_clear_error();
- nread = SSL_read(ssl_handle, buf, sizeof(buf));
+ while (!done && data_available(ftp, fd)) {
+ ERR_clear_error();
+ nread = SSL_read(ssl_handle, buf, sizeof(buf));
+ if (nread <= 0) {
err = SSL_get_error(ssl_handle, nread);
switch (err) {
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) {
break;
default:
if ((sslerror = ERR_get_error())) {
- ERR_error_string_n(sslerror, buf, sizeof(buf));
+ ERR_error_string_n(sslerror, buf, sizeof(buf));
+ php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s", buf);
+ } else if (errno) {
+ php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", strerror(errno), errno);
}
- php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", (sslerror ? buf : strerror(errno)), errno);
done = 1;
break;
}