[PATCH v2] wininet: Allow up to 4K for data buffers
Alistair Leslie-Hughes
leslie_alistair at hotmail.com
Wed Oct 6 23:36:26 CDT 2021
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>
---
dlls/wininet/internet.h | 2 +-
dlls/wininet/tests/http.c | 54 +++++++++++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+), 1 deletion(-)
diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h
index e9d68e2c2d9..8538699811c 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..ace2291fe5c 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -44,6 +44,8 @@
static BOOL first_connection_to_test_url = TRUE;
static BOOL https_support = TRUE;
+#define HEADER_VALUE_SIZE 4098
+
/* Adapted from dlls/urlmon/tests/protocol.c */
#define SET_EXPECT2(status, num) \
@@ -2410,6 +2412,22 @@ 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_length"))
+ {
+ static const char allokmsg[] = "HTTP/1.1 200 OK\r\nCache-Control: no-cache\r\n"
+ "Server: winetest\r\n";
+
+ char *p = HeapAlloc(GetProcessHeap(), 0, HEADER_VALUE_SIZE + 13 );
+ strcpy(p, "wine-header: ");
+ memset(p+13, 'A', HEADER_VALUE_SIZE);
+ p[HEADER_VALUE_SIZE+12] = 0;
+
+ send(c, allokmsg, sizeof(allokmsg)-1, 0);
+ send(c, p, HEADER_VALUE_SIZE + 12, 0);
+ send(c, "\r\n\r\n", 4, 0);
+
+ HeapFree(GetProcessHeap(), 0, p);
+ }
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 +3634,41 @@ static void test_not_modified(int port)
InternetCloseHandle(ses);
}
+static void test_header_length_value(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_length", 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 == HEADER_VALUE_SIZE, "got %u\n", size);
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+}
+
static void test_conn_close(int port)
{
HINTERNET session, connection, req;
@@ -6190,6 +6243,7 @@ static void test_http_connection(void)
test_options(si.port);
test_no_content(si.port);
test_not_modified(si.port);
+ test_header_length_value(si.port);
test_conn_close(si.port);
test_no_cache(si.port);
test_cache_read_gzipped(si.port);
--
2.33.0
More information about the wine-devel
mailing list