Skip to content

Commit ad60606

Browse files
committed
Merge branch 'PHP-7.3'
* PHP-7.3: NEWS NEWS NEWS Fix #77151 ftp_close(): SSL_read on shutdown
2 parents 1f3a535 + 3ed07cc commit ad60606

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

1909-
while (!done) {
1910-
if (data_available(ftp, fd)) {
1911-
ERR_clear_error();
1912-
nread = SSL_read(ssl_handle, buf, sizeof(buf));
1909+
while (!done && data_available(ftp, fd)) {
1910+
ERR_clear_error();
1911+
nread = SSL_read(ssl_handle, buf, sizeof(buf));
1912+
if (nread <= 0) {
19131913
err = SSL_get_error(ssl_handle, nread);
19141914
switch (err) {
19151915
case SSL_ERROR_NONE: /* this is not an error */
@@ -1927,9 +1927,11 @@ static void ftp_ssl_shutdown(ftpbuf_t *ftp, php_socket_t fd, SSL *ssl_handle) {
19271927
break;
19281928
default:
19291929
if ((sslerror = ERR_get_error())) {
1930-
ERR_error_string_n(sslerror, buf, sizeof(buf));
1930+
ERR_error_string_n(sslerror, buf, sizeof(buf));
1931+
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s", buf);
1932+
} else if (errno) {
1933+
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", strerror(errno), errno);
19311934
}
1932-
php_error_docref(NULL, E_WARNING, "SSL_read on shutdown: %s (%d)", (sslerror ? buf : strerror(errno)), errno);
19331935
done = 1;
19341936
break;
19351937
}

0 commit comments

Comments
 (0)