Skip to content

Commit 6ce4be1

Browse files
committed
Merge branch 'PHP-7.1' into PHP-7.2
* PHP-7.1: NEWS Fix #77151 ftp_close(): SSL_read on shutdown
2 parents 6742b4b + 1adbf70 commit 6ce4be1

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
@@ -1908,10 +1908,10 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
19081908
done = 0;
19091909
}
19101910

1911-
while (!done) {
1912-
if (data_available(ftp, fd)) {
1913-
ERR_clear_error();
1914-
nread = SSL_read(ssl_handle, buf, sizeof(buf));
1911+
while (!done && data_available(ftp, fd)) {
1912+
ERR_clear_error();
1913+
nread = SSL_read(ssl_handle, buf, sizeof(buf));
1914+
if (nread <= 0) {
19151915
err = SSL_get_error(ssl_handle, nread);
19161916
switch (err) {
19171917
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) {
19291929
break;
19301930
default:
19311931
if ((sslerror = ERR_get_error())) {
1932-
ERR_error_string_n(sslerror, buf, sizeof(buf));
1932+
ERR_error_string_n(sslerror, buf, sizeof(buf));
1933+
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s", buf);
1934+
} else if (errno) {
1935+
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", strerror(errno), errno);
19331936
}
1934-
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", (sslerror ? buf : strerror(errno)), errno);
19351937
done = 1;
19361938
break;
19371939
}

0 commit comments

Comments
 (0)