Skip to content

Commit 408b172

Browse files
committed
Revert xp_ssl.c to the state of 5.4.32 due to regressions
1 parent e64da8c commit 408b172

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

ext/openssl/xp_ssl.c

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -204,59 +204,13 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
204204
return didwrite;
205205
}
206206

207-
static void php_openssl_stream_wait_for_data(php_netstream_data_t *sock)
208-
{
209-
int retval;
210-
struct timeval *ptimeout;
211-
212-
if (sock->socket == -1) {
213-
return;
214-
}
215-
216-
sock->timeout_event = 0;
217-
218-
if (sock->timeout.tv_sec == -1)
219-
ptimeout = NULL;
220-
else
221-
ptimeout = &sock->timeout;
222-
223-
while(1) {
224-
retval = php_pollfd_for(sock->socket, PHP_POLLREADABLE, ptimeout);
225-
226-
if (retval == 0)
227-
sock->timeout_event = 1;
228-
229-
if (retval >= 0)
230-
break;
231-
232-
if (php_socket_errno() != EINTR)
233-
break;
234-
}
235-
}
236-
237207
static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS_DC)
238208
{
239209
php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract;
240-
php_netstream_data_t *sock;
241210
int nr_bytes = 0;
242211

243212
if (sslsock->ssl_active) {
244213
int retry = 1;
245-
sock = (php_netstream_data_t*)stream->abstract;
246-
247-
/* The SSL_read() function will block indefinitely waiting for data on a blocking
248-
socket. If we don't poll for readability first this operation has the potential
249-
to hang forever. To avoid this scenario we poll with a timeout before performing
250-
the actual read. If it times out we're finished.
251-
*/
252-
if (sock->is_blocked && SSL_pending(sslsock->ssl_handle) == 0) {
253-
php_openssl_stream_wait_for_data(sock);
254-
if (sock->timeout_event) {
255-
stream->eof = 1;
256-
php_error_docref(NULL TSRMLS_CC, E_WARNING, "SSL read operation timed out");
257-
return nr_bytes;
258-
}
259-
}
260214

261215
do {
262216
nr_bytes = SSL_read(sslsock->ssl_handle, buf, count);
@@ -871,21 +825,6 @@ static int php_openssl_sockop_cast(php_stream *stream, int castas, void **ret TS
871825

872826
case PHP_STREAM_AS_FD_FOR_SELECT:
873827
if (ret) {
874-
/* OpenSSL has an internal buffer which select() cannot see. If we don't
875-
* fetch it into the stream's buffer, no activity will be reported on the
876-
* stream even though there is data waiting to be read - but we only fetch
877-
* the lower of bytes OpenSSL has ready to give us or chunk_size since we
878-
* weren't asked for any data at this stage. This is only likely to cause
879-
* issues with non-blocking streams, but it's harmless to always do it. */
880-
size_t pending;
881-
if (stream->writepos == stream->readpos
882-
&& sslsock->ssl_active
883-
&& (pending = (size_t)SSL_pending(sslsock->ssl_handle)) > 0) {
884-
php_stream_fill_read_buffer(stream, pending < stream->chunk_size
885-
? pending
886-
: stream->chunk_size);
887-
}
888-
889828
*(int *)ret = sslsock->s.socket;
890829
}
891830
return SUCCESS;

0 commit comments

Comments
 (0)