@@ -88,15 +88,16 @@ MYSQLND_METHOD(mysqlnd_net, network_read_ex)(MYSQLND_NET * const net, zend_uchar
88
88
enum_func_status return_value = PASS ;
89
89
php_stream * net_stream = net -> data -> m .get_stream (net );
90
90
size_t old_chunk_size = net_stream -> chunk_size ;
91
- size_t to_read = count , ret ;
91
+ size_t to_read = count ;
92
92
zend_uchar * p = buffer ;
93
93
94
94
DBG_ENTER ("mysqlnd_net::network_read_ex" );
95
95
DBG_INF_FMT ("count=" MYSQLND_SZ_T_SPEC , count );
96
96
97
97
net_stream -> chunk_size = MIN (to_read , net -> data -> options .net_read_buffer_size );
98
98
while (to_read ) {
99
- if (!(ret = php_stream_read (net_stream , (char * ) p , to_read ))) {
99
+ ssize_t ret = php_stream_read (net_stream , (char * ) p , to_read );
100
+ if (ret <= 0 ) {
100
101
DBG_ERR_FMT ("Error while reading header from socket" );
101
102
return_value = FAIL ;
102
103
break ;
@@ -866,20 +867,24 @@ MYSQLND_METHOD(mysqlnd_net, consume_uneaten_data)(MYSQLND_NET * const net, enum
866
867
867
868
if (PHP_STREAM_OPTION_RETURN_ERR != was_blocked ) {
868
869
/* Do a read of 1 byte */
869
- int bytes_consumed ;
870
+ ssize_t bytes_consumed ;
870
871
871
872
do {
872
- skipped_bytes += (bytes_consumed = php_stream_read (net_stream , tmp_buf , sizeof (tmp_buf )));
873
+ bytes_consumed = php_stream_read (net_stream , tmp_buf , sizeof (tmp_buf ));
874
+ if (bytes_consumed <= 0 ) {
875
+ break ;
876
+ }
877
+ skipped_bytes += bytes_consumed ;
873
878
} while (bytes_consumed == sizeof (tmp_buf ));
874
879
875
880
if (was_blocked ) {
876
881
net_stream -> ops -> set_option (net_stream , opt , 1 , NULL );
877
882
}
878
883
879
884
if (bytes_consumed ) {
880
- DBG_ERR_FMT ("Skipped %u bytes. Last command %s hasn't consumed all the output from the server" ,
885
+ DBG_ERR_FMT ("Skipped %zu bytes. Last command %s hasn't consumed all the output from the server" ,
881
886
bytes_consumed , mysqlnd_command_to_text [net -> last_command ]);
882
- php_error_docref (NULL , E_WARNING , "Skipped %u bytes. Last command %s hasn't "
887
+ php_error_docref (NULL , E_WARNING , "Skipped %zu bytes. Last command %s hasn't "
883
888
"consumed all the output from the server" ,
884
889
bytes_consumed , mysqlnd_command_to_text [net -> last_command ]);
885
890
}
0 commit comments