summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lowrey <rdlowrey@php.net>2015-04-14 09:12:28 -0600
committerDaniel Lowrey <rdlowrey@php.net>2015-04-14 09:25:11 -0600
commit81f356b4aea79cd8f86e16096c7ccfbc455bfc3c (patch)
tree9d9e9e4146d647d406c87ee399519fb514084841
parented7e6d4758b8a8999b5e29e144e394782d473654 (diff)
downloadphp-git-81f356b4aea79cd8f86e16096c7ccfbc455bfc3c.tar.gz
Fix Bug #69402: Reading empty SSL stream hangs until timeout
-rw-r--r--ext/openssl/xp_ssl.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index adef9120d6..e24d32cd45 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -1826,7 +1826,7 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
{
php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract;
int nr_bytes = 0;
-
+
/* Only do this if SSL is active. */
if (sslsock->ssl_active) {
int retry = 1;
@@ -1910,13 +1910,18 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
/* Also, on reads, we may get this condition on an EOF. We should check properly. */
if (read) {
- stream->eof = (retry == 0 && errno != EAGAIN && !SSL_pending(sslsock->ssl_handle));
+ stream->eof = (retry == 0 && errno != EAGAIN && !SSL_pending(sslsock->ssl_handle));
}
-
+
+ /* Don't loop indefinitely in non-blocking mode if no data is available */
+ if (began_blocked == 0) {
+ break;
+ }
+
/* Now, if we have to wait some time, and we're supposed to be blocking, wait for the socket to become
* available. Now, php_pollfd_for uses select to wait up to our time_left value only...
*/
- if (retry && began_blocked) {
+ if (retry) {
if (read) {
php_pollfd_for(sslsock->s.socket, (err == SSL_ERROR_WANT_WRITE) ?
(POLLOUT|POLLPRI) : (POLLIN|POLLPRI), has_timeout ? &left_time : NULL);