Module: wine Branch: master Commit: 09238973e82bdb9e17637319c02389f7d0db0b48 URL: http://source.winehq.org/git/wine.git/?a=commit;h=09238973e82bdb9e17637319c0...
Author: Hans Leidekker hans@codeweavers.com Date: Wed Jun 21 09:39:10 2017 +0200
winhttp: Only read as much data as advertized when draining content.
Fixes a regression caused by 2fa86fd6616e1671dd3ecfa3d2d6eaccf10be994.
Signed-off-by: Hans Leidekker hans@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/winhttp/request.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c index db6d12d..f35d73b 100644 --- a/dlls/winhttp/request.c +++ b/dlls/winhttp/request.c @@ -1302,13 +1302,20 @@ done: /* read any content returned by the server so that the connection can be reused */ static void drain_content( request_t *request ) { - DWORD bytes_read; + DWORD size, bytes_read, bytes_total = 0, bytes_left = request->content_length - request->content_read; char buffer[2048];
refill_buffer( request, FALSE ); for (;;) { - if (!read_data( request, buffer, sizeof(buffer), &bytes_read, FALSE ) || !bytes_read) return; + if (request->read_chunked) size = sizeof(buffer); + else + { + if (bytes_total >= bytes_left) return; + size = min( sizeof(buffer), bytes_left - bytes_total ); + } + if (!read_data( request, buffer, size, &bytes_read, FALSE ) || !bytes_read) return; + bytes_total += bytes_read; } }