Skip to content

Commit

Permalink
Fix #77151 ftp_close(): SSL_read on shutdown
Browse files Browse the repository at this point in the history
Regression introduced in fix for #76972

only display the error message when sslerror
or if errno is set (for SSL_ERROR_SYSCALL case)
  • Loading branch information
remicollet committed Nov 20, 2018
1 parent 3e78380 commit d9afc2f
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions ext/ftp/ftp.c
Expand Up @@ -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 */
Expand All @@ -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;
}
Expand Down

0 comments on commit d9afc2f

Please sign in to comment.