summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/openssl/xp_ssl.c16
-rw-r--r--main/streams/xp_socket.c13
2 files changed, 24 insertions, 5 deletions
diff --git a/ext/openssl/xp_ssl.c b/ext/openssl/xp_ssl.c
index 69f11a287e..5e7aad4039 100644
--- a/ext/openssl/xp_ssl.c
+++ b/ext/openssl/xp_ssl.c
@@ -122,7 +122,7 @@ static int handle_ssl_error(php_stream *stream, int nr_bytes TSRMLS_DC)
static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
{
php_openssl_netstream_data_t *sslsock = (php_openssl_netstream_data_t*)stream->abstract;
- size_t didwrite;
+ int didwrite;
if (sslsock->ssl_active) {
int retry = 1;
@@ -141,9 +141,14 @@ static size_t php_openssl_sockop_write(php_stream *stream, const char *buf, size
didwrite = php_stream_socket_ops.write(stream, buf, count TSRMLS_CC);
}
- if (didwrite > 0)
+ if (didwrite > 0) {
php_stream_notify_progress_increment(stream->context, didwrite, 0);
+ }
+ if (didwrite < 0) {
+ didwrite = 0;
+ }
+
return didwrite;
}
@@ -174,8 +179,13 @@ static size_t php_openssl_sockop_read(php_stream *stream, char *buf, size_t coun
nr_bytes = php_stream_socket_ops.read(stream, buf, count TSRMLS_CC);
}
- if (nr_bytes > 0)
+ if (nr_bytes > 0) {
php_stream_notify_progress_increment(stream->context, nr_bytes, 0);
+ }
+
+ if (nr_bytes < 0) {
+ nr_bytes = 0;
+ }
return nr_bytes;
}
diff --git a/main/streams/xp_socket.c b/main/streams/xp_socket.c
index 10674fff9f..56ae6dba75 100644
--- a/main/streams/xp_socket.c
+++ b/main/streams/xp_socket.c
@@ -46,7 +46,7 @@ static int php_tcp_sockop_set_option(php_stream *stream, int option, int value,
static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count TSRMLS_DC)
{
php_netstream_data_t *sock = (php_netstream_data_t*)stream->abstract;
- size_t didwrite;
+ int didwrite;
if (sock->socket == -1) {
return 0;
@@ -66,6 +66,10 @@ static size_t php_sockop_write(php_stream *stream, const char *buf, size_t count
php_stream_notify_progress_increment(stream->context, didwrite, 0);
}
+ if (didwrite < 0) {
+ didwrite = 0;
+ }
+
return didwrite;
}
@@ -124,8 +128,13 @@ static size_t php_sockop_read(php_stream *stream, char *buf, size_t count TSRMLS
stream->eof = 1;
}
- if (nr_bytes > 0)
+ if (nr_bytes > 0) {
php_stream_notify_progress_increment(stream->context, nr_bytes, 0);
+ }
+
+ if (nr_bytes < 0) {
+ nr_bytes = 0;
+ }
return nr_bytes;
}