From: Joao Matos Date: Thu, 27 Oct 2016 19:35:20 +0000 (+0100) Subject: [System.IO.Compression] Fixed potential bug when keeping track of total read bytes... X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=dd0745f42631963648f7372689cbe4805400285f;p=mono.git [System.IO.Compression] Fixed potential bug when keeping track of total read bytes of input stream. This didn't manifest as a bug, to to be on the safe side, replicate the behavior introduced in https://github.com/mono/mono/commit/b4d5016b5e42fec226d93fd13260b6cac80eb384 and use the same approach when calculating the total of the read bytes of the input stream. --- diff --git a/support/zlib-helper.c b/support/zlib-helper.c index 5a33d0f2b8e..9dcebc7e967 100644 --- a/support/zlib-helper.c +++ b/support/zlib-helper.c @@ -194,9 +194,10 @@ ReadZStream (ZStream *stream, guchar *buffer, gint length) while (zs->avail_out > 0) { if (zs->avail_in == 0) { n = stream->func (stream->buffer, BUFFER_SIZE, stream->gchandle); + n = n < 0 ? 0 : n; stream->total_in += n; zs->next_in = stream->buffer; - zs->avail_in = n < 0 ? 0 : n; + zs->avail_in = n; } if (zs->avail_in == 0 && zs->total_in == 0)