Alistair Leslie-Hughes : wininet: Allow up to 4K for response headers.

Alexandre Julliard julliard at winehq.org
Fri Feb 25 07:30:25 CST 2022


Module: wine
Branch: oldstable
Commit: b56d5b9a4794a3ebe2b3b398328da9462bb9372d
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=b56d5b9a4794a3ebe2b3b398328da9462bb9372d

Author: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date:   Thu Oct  7 13:58:05 2021 +0200

wininet: Allow up to 4K for response headers.

LevelHead includes a Header value that is > 3K in length which
causes a crash after linking your account.

Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=47505
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Signed-off-by: Hans Leidekker <hans at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
(cherry picked from commit 42920ad653db4514532ee713467856e5abc5b126)
Signed-off-by: Michael Stefaniuc <mstefani at winehq.org>

---

 dlls/wininet/internet.h   |  2 +-
 dlls/wininet/tests/http.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)

diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index 0efea473255..3e248224769 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -459,7 +459,7 @@ void free_authorization_cache(void) DECLSPEC_HIDDEN;
 
 void init_winsock(void) DECLSPEC_HIDDEN;
 
-#define MAX_REPLY_LEN	 	0x5B4
+#define MAX_REPLY_LEN   0x1000
 
 /* Used for debugging - maybe need to be shared in the Wine debugging code ? */
 typedef struct
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 1617e4e85c3..1620b7a7e3f 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2434,6 +2434,17 @@ static DWORD CALLBACK server_thread(LPVOID param)
             static const char headmsg[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\n0123456789";
             send(c, headmsg, sizeof(headmsg)-1, 0);
         }
+        if (strstr(buffer, "GET /test_large_header"))
+        {
+            static const char allokmsg[] =  "HTTP/1.1 200 OK\r\nServer: winetest\r\n";
+            char header[4000 + sizeof("wine-header: ") - 1];
+
+            memset(header, 'A', sizeof(header));
+            memcpy(header, "wine-header: ", sizeof("wine-header: ") - 1);
+            send(c, allokmsg, sizeof(allokmsg) - 1, 0);
+            send(c, header, sizeof(header), 0);
+            send(c, "\r\n\r\n", 4, 0);
+        }
         if (strstr(buffer, "GET /test_conn_close"))
         {
             static const char conn_close_response[] = "HTTP/1.1 200 OK\r\nConnection: close\r\n\r\nsome content";
@@ -3640,6 +3651,41 @@ static void test_not_modified(int port)
     InternetCloseHandle(ses);
 }
 
+static void test_large_header(int port)
+{
+    HINTERNET ses, con, req;
+    BOOL ret;
+    DWORD size, index, error;
+    char buffer[13];
+
+    ses = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+    ok(ses != NULL, "InternetOpen failed\n");
+
+    con = InternetConnectA(ses, "localhost", port, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
+    ok(con != NULL, "InternetConnect failed\n");
+
+    req = HttpOpenRequestA(con, NULL, "/test_large_header", NULL, NULL, NULL, 0, 0);
+    ok(req != NULL, "HttpOpenRequest failed\n");
+
+    SetLastError(0xdeadbeef);
+    ret = HttpSendRequestW(req, NULL, 0, NULL, 0);
+    ok(ret, "HttpSendRequest failed: %u\n", GetLastError());
+    test_status_code(req, 200);
+
+    index = 0;
+    size = sizeof(buffer);
+    strcpy(buffer, "wine-header");
+    ret = HttpQueryInfoA(req, HTTP_QUERY_CUSTOM, buffer, &size, &index);
+    error = GetLastError();
+    ok(!ret, "HttpQueryInfoA succeeded\n");
+    ok(error == ERROR_INSUFFICIENT_BUFFER, "expected ERROR_INSUFFICIENT_BUFFER, got %u\n", error);
+    ok(size == 4001, "got %u\n", size);
+
+    InternetCloseHandle(req);
+    InternetCloseHandle(con);
+    InternetCloseHandle(ses);
+}
+
 static void test_conn_close(int port)
 {
     HINTERNET session, connection, req;
@@ -6214,6 +6260,7 @@ static void test_http_connection(void)
     test_options(si.port);
     test_no_content(si.port);
     test_not_modified(si.port);
+    test_large_header(si.port);
     test_conn_close(si.port);
     test_no_cache(si.port);
     test_cache_read_gzipped(si.port);




More information about the wine-cvs mailing list