Jacek Caban : wininet: Make sure to not read over chunk end in read_gzip_data.
Alexandre Julliard
julliard at winehq.org
Thu Dec 17 10:37:08 CST 2009
Module: wine
Branch: master
Commit: 78b2cedaa616a92ef8ac542ffd646280ac2bcf77
URL: http://source.winehq.org/git/wine.git/?a=commit;h=78b2cedaa616a92ef8ac542ffd646280ac2bcf77
Author: Jacek Caban <jacek at codeweavers.com>
Date: Thu Dec 17 00:02:47 2009 +0100
wininet: Make sure to not read over chunk end in read_gzip_data.
---
dlls/wininet/http.c | 9 ++++++---
1 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 5dfbe6a..6786380 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -1952,6 +1952,7 @@ static DWORD read_gzip_data(http_request_t *req, BYTE *buf, int size, BOOL sync,
#ifdef HAVE_ZLIB
z_stream *zstream = &req->gzip_stream->zstream;
+ DWORD buf_avail;
int zres;
while(read < size && !req->gzip_stream->end_of_data) {
@@ -1960,14 +1961,16 @@ static DWORD read_gzip_data(http_request_t *req, BYTE *buf, int size, BOOL sync,
break;
}
+ buf_avail = req->dwContentLength == ~0 ? req->read_size : min(req->read_size, req->dwContentLength-req->dwContentRead);
+
zstream->next_in = req->read_buf+req->read_pos;
- zstream->avail_in = req->read_size;
+ zstream->avail_in = buf_avail;
zstream->next_out = buf+read;
zstream->avail_out = size-read;
zres = inflate(zstream, Z_FULL_FLUSH);
read = size - zstream->avail_out;
- req->dwContentRead += req->read_size-zstream->avail_in;
- remove_data(req, req->read_size-zstream->avail_in);
+ req->dwContentRead += buf_avail-zstream->avail_in;
+ remove_data(req, buf_avail-zstream->avail_in);
if(zres == Z_STREAM_END) {
TRACE("end of data\n");
req->gzip_stream->end_of_data = TRUE;
More information about the wine-cvs
mailing list