[1/3] wininet: Don't return available data sizes larger than the read buffer.

Hans Leidekker hans at codeweavers.com
Tue Jul 19 04:27:35 CDT 2016


Signed-off-by: Hans Leidekker <hans at codeweavers.com>
---
 dlls/wininet/http.c       |  2 +-
 dlls/wininet/tests/http.c | 13 ++++++++++---
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 5436a89..2c62d97 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2613,7 +2613,7 @@ static DWORD refill_read_buffer(http_request_t *req, blocking_mode_t blocking_mo
 /* return the size of data available to be read immediately (the read section must be held) */
 static DWORD get_avail_data( http_request_t *req )
 {
-    return req->read_size + req->data_stream->vtbl->get_avail_data(req->data_stream, req);
+    return min(READ_BUFFER_SIZE, req->read_size + req->data_stream->vtbl->get_avail_data(req->data_stream, req));
 }
 
 static DWORD netconn_get_avail_data(data_stream_t *stream, http_request_t *req)
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index e84ffa3..3b06fb9 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -162,6 +162,13 @@ static const test_data_t test_data[] = {
         0,
         "mode=Test",
         "mode => Test\n"
+    },
+    {
+        "http://test.winehq.org/data/",
+        "http://test.winehq.org/data/",
+        "test.winehq.org",
+        "/data/",
+        ""
     }
 };
 
@@ -793,7 +800,7 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
             {
                 trace("PENDING\n");
                 /* on some tests, InternetQueryDataAvailable returns non-zero length and ERROR_IO_PENDING */
-                if(!(test->flags & TESTF_CHUNKED))
+                if(test->flags && !(test->flags & TESTF_CHUNKED))
                     ok(!length, "InternetQueryDataAvailable returned ERROR_IO_PENDING and %u length\n", length);
                 WaitForSingleObject(hCompleteEvent, INFINITE);
                 exlen = length;
@@ -811,8 +818,7 @@ static void InternetReadFile_test(int flags, const test_data_t *test)
         CLEAR_NOTIFIED(INTERNET_STATUS_RESPONSE_RECEIVED);
 
         trace("LENGTH %d\n", length);
-        if(test->flags & TESTF_CHUNKED)
-            ok(length <= 8192, "length = %d, expected <= 8192\n", length);
+        ok(length <= 8192 || broken(length <= 16384) /* < win7 */, "length = %d, expected <= 8192\n", length);
         if (length)
         {
             char *buffer;
@@ -6272,6 +6278,7 @@ START_TEST(http)
     InternetReadFile_chunked_test();
     HttpSendRequestEx_test();
     InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[3]);
+    InternetReadFile_test(INTERNET_FLAG_ASYNC, &test_data[4]);
     test_connection_failure();
     test_default_service_port();
     test_concurrent_header_access();
-- 
2.8.1




More information about the wine-patches mailing list