diff options
author | Remi Collet <remi@php.net> | 2018-11-20 11:19:52 +0100 |
---|---|---|
committer | Remi Collet <remi@php.net> | 2018-11-20 11:19:52 +0100 |
commit | 6ce4be17621a3a62a659755a90a5d3ad734ba2e8 (patch) | |
tree | 7605c215e9e78f8842232e8eea1909a12825b027 | |
parent | 6742b4b7cc67cf586bcaf9f321f211657ca42dee (diff) | |
parent | 1adbf70e26c7d515ffb7b08248707214218089e8 (diff) | |
download | php-git-6ce4be17621a3a62a659755a90a5d3ad734ba2e8.tar.gz |
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1:
NEWS
Fix #77151 ftp_close(): SSL_read on shutdown
-rw-r--r-- | ext/ftp/ftp.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c index 09aa43a42c..fd8b7363a7 100644 --- a/ext/ftp/ftp.c +++ b/ext/ftp/ftp.c @@ -1908,10 +1908,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 */ @@ -1929,9 +1929,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; } |