Added wininet-handle-403-error patchset

This commit is contained in:
Alistair Leslie-Hughes 2021-09-17 12:48:01 +10:00
parent 7b01b9eb20
commit e7c298c616
3 changed files with 109 additions and 0 deletions

View File

@ -271,6 +271,7 @@ patch_enable_all ()
enable_winex11_wglShareLists="$1"
enable_winex11_drv_Query_server_position="$1"
enable_wininet_Cleanup="$1"
enable_wininet_handle_403_error="$1"
enable_winmm_mciSendCommandA="$1"
enable_wintab32_improvements="$1"
enable_wintrust_WTHelperGetProvCertFromChain="$1"
@ -851,6 +852,9 @@ patch_enable ()
wininet-Cleanup)
enable_wininet_Cleanup="$2"
;;
wininet-handle-403-error)
enable_wininet_handle_403_error="$2"
;;
winmm-mciSendCommandA)
enable_winmm_mciSendCommandA="$2"
;;
@ -4082,6 +4086,18 @@ if test "$enable_wininet_Cleanup" -eq 1; then
patch_apply wininet-Cleanup/0005-wininet-Replacing-header-fields-should-fail-if-they-.patch
fi
# Patchset wininet-handle-403-error
# |
# | This patchset fixes the following Wine bugs:
# | * [#47505] Stop LevelHead disconnection on startup.
# |
# | Modified files:
# | * dlls/wininet/http.c, dlls/wininet/tests/http.c
# |
if test "$enable_wininet_handle_403_error" -eq 1; then
patch_apply wininet-handle-403-error/0001-wininet-Set-context-length-for-http-status-403.patch
fi
# Patchset winmm-mciSendCommandA
# |
# | Modified files:

View File

@ -0,0 +1,91 @@
From 896e09b2e5992abe60890928c7593487512b9328 Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
Date: Wed, 1 Sep 2021 17:14:08 +1000
Subject: [PATCH 1/2] wininet: Set context length for http status 403
Signed-off-by: Alistair Leslie-Hughes <leslie_alistair@hotmail.com>
---
dlls/wininet/http.c | 4 +++-
dlls/wininet/tests/http.c | 37 +++++++++++++++++++++++++++++++++++++
2 files changed, 40 insertions(+), 1 deletion(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 203afb7d312..49c57a9c4e5 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2927,7 +2927,9 @@ static DWORD set_content_length(http_request_t *request)
WCHAR encoding[20];
DWORD size;
- if(request->status_code == HTTP_STATUS_NO_CONTENT || !wcscmp(request->verb, L"HEAD")) {
+ if(request->status_code == HTTP_STATUS_NO_CONTENT || request->status_code == HTTP_STATUS_NOT_MODIFIED ||
+ !wcscmp(request->verb, L"HEAD"))
+ {
request->contentLength = request->netconn_stream.content_length = 0;
return ERROR_SUCCESS;
}
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 0e0748c02ef..b6cfdb30f5c 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -2397,6 +2397,11 @@ static DWORD CALLBACK server_thread(LPVOID param)
static const char nocontentmsg[] = "HTTP/1.1 204 No Content\r\nConnection: close\r\n\r\n";
send(c, nocontentmsg, sizeof(nocontentmsg)-1, 0);
}
+ if (strstr(buffer, "GET /test_not_modified"))
+ {
+ static const char notmodifiedmsg[] = "HTTP/1.1 304 Not Modified\r\nConnection: close\r\n\r\n";
+ send(c, notmodifiedmsg, sizeof(notmodifiedmsg)-1, 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";
@@ -3709,6 +3714,37 @@ static void test_no_content(int port)
CHECK_NOTIFIED(INTERNET_STATUS_CONNECTION_CLOSED);
}
+static void test_not_modified(int port)
+{
+ DWORD len;
+ char buf[256];
+ HINTERNET ses, con, req;
+ BOOL ret;
+
+ 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_not_modified", 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, 304);
+
+ len = sizeof(buf)-1;
+ ret = HttpQueryInfoA(req, HTTP_QUERY_CONTENT_LENGTH, buf, &len, 0);
+ ok(!ret, "HttpQueryInfo should have failed\n");
+ ok(GetLastError() == ERROR_HTTP_HEADER_NOT_FOUND , "got %u\n", GetLastError());
+
+ InternetCloseHandle(req);
+ InternetCloseHandle(con);
+ InternetCloseHandle(ses);
+}
+
static void test_conn_close(int port)
{
HINTERNET session, connection, req;
@@ -6334,6 +6370,7 @@ static void test_http_connection(void)
test_HttpSendRequestW(si.port);
test_options(si.port);
test_no_content(si.port);
+ test_not_modified(si.port);
test_conn_close(si.port);
test_no_cache(si.port);
test_cache_read_gzipped(si.port);
--
2.33.0

View File

@ -0,0 +1,2 @@
# This is only a partial fix, a crash can still occur on the initial screen.
Fixes: [47505] Stop LevelHead disconnection on startup.