Alistair Leslie-Hughes : wininet: Allow up to 4K for response headers.
Alexandre Julliard
julliard at winehq.org
Thu Oct 7 16:21:21 CDT 2021
Module: wine
Branch: master
Commit: 42920ad653db4514532ee713467856e5abc5b126
URL: https://source.winehq.org/git/wine.git/?a=commit;h=42920ad653db4514532ee713467856e5abc5b126
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>
---
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 e9d68e2c2d9..b361c0d1b4d 100644
--- a/dlls/wininet/internet.h
+++ b/dlls/wininet/internet.h
@@ -462,7 +462,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 ae95b4399e0..d1d7e678853 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2410,6 +2410,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";
@@ -3616,6 +3627,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;
@@ -6190,6 +6236,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