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@hotmail.com>
Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
(cherry picked from commit 42920ad653)
Signed-off-by: Michael Stefaniuc <mstefani@winehq.org>
This commit is contained in:
Alistair Leslie-Hughes 2021-10-07 13:58:05 +02:00 committed by Michael Stefaniuc
parent a6af1e31dd
commit b56d5b9a47
2 changed files with 48 additions and 1 deletions

View File

@ -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

View File

@ -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);