From: Hans Leidekker Subject: wininet: Reading past end-of-file in chunked mode returns success. Message-Id: <1385052774.14913.53.camel@t400> Date: Thu, 21 Nov 2013 17:52:54 +0100 Found by Andrew Eikum. --- dlls/wininet/http.c | 2 +- dlls/wininet/tests/http.c | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index 9c2d5d4..52b64f8 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -2761,7 +2761,7 @@ static DWORD start_next_chunk(chunked_stream_t *stream, http_request_t *req) assert(!stream->chunk_size || stream->chunk_size == ~0u); - if (stream->end_of_data) return ERROR_NO_MORE_FILES; + if (stream->end_of_data) return ERROR_SUCCESS; /* read terminator for the previous chunk */ if(!stream->chunk_size && (res = discard_chunked_eol(stream, req)) != ERROR_SUCCESS) diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c index 7b7a33c..ffb5fdf 100644 --- a/dlls/wininet/tests/http.c +++ b/dlls/wininet/tests/http.c @@ -734,7 +734,7 @@ static void InternetReadFile_chunked_test(void) { BOOL res; CHAR buffer[4000]; - DWORD length; + DWORD length, got; const char *types[2] = { "*", NULL }; HINTERNET hi, hic = 0, hor = 0; @@ -814,7 +814,6 @@ static void InternetReadFile_chunked_test(void) trace("got %u available\n",length); if (length) { - DWORD got; char *buffer = HeapAlloc(GetProcessHeap(),0,length+1); res = InternetReadFile(hor,buffer,length,&got); @@ -828,7 +827,13 @@ static void InternetReadFile_chunked_test(void) if (!got) break; } if (length == 0) + { + got = 0xdeadbeef; + res = InternetReadFile( hor, buffer, 1, &got ); + ok( res, "InternetReadFile failed: %u\n", GetLastError() ); + ok( !got, "got %u\n", got ); break; + } } abort: trace("aborting\n"); -- 1.8.4.2