Added patch to fix handling of INTERNET_INVALID_PORT_NUMBER in HttpOpenRequestW.

This commit is contained in:
Sebastian Lackner 2016-03-20 08:59:21 +01:00
parent 3d7ac2bee6
commit 44b64cc18e
3 changed files with 138 additions and 0 deletions

View File

@ -373,6 +373,7 @@ patch_enable_all ()
enable_winex11_wglShareLists="$1"
enable_winhttp_System_Proxy_Autoconfig="$1"
enable_wininet_Cleanup="$1"
enable_wininet_HttpOpenRequestW="$1"
enable_wininet_Internet_Settings="$1"
enable_wininet_ParseX509EncodedCertificateForListBoxEntry="$1"
enable_winmm_Delay_Import_Depends="$1"
@ -1286,6 +1287,9 @@ patch_enable ()
wininet-Cleanup)
enable_wininet_Cleanup="$2"
;;
wininet-HttpOpenRequestW)
enable_wininet_HttpOpenRequestW="$2"
;;
wininet-Internet_Settings)
enable_wininet_Internet_Settings="$2"
;;
@ -7313,6 +7317,21 @@ if test "$enable_wininet_Cleanup" -eq 1; then
) >> "$patchlist"
fi
# Patchset wininet-HttpOpenRequestW
# |
# | This patchset fixes the following Wine bugs:
# | * [#40169] Fix handling of INTERNET_INVALID_PORT_NUMBER in HttpOpenRequestW
# |
# | Modified files:
# | * dlls/wininet/http.c, dlls/wininet/tests/http.c
# |
if test "$enable_wininet_HttpOpenRequestW" -eq 1; then
patch_apply wininet-HttpOpenRequestW/0001-wininet-Set-default-HTTP-port-correctly-when-passing.patch
(
echo '+ { "Michael Müller", "wininet: Set default HTTP port correctly when passing INTERNET_FLAG_SECURE to InternetConnect.", 1 },';
) >> "$patchlist"
fi
# Patchset wininet-Internet_Settings
# |
# | Modified files:

View File

@ -0,0 +1,118 @@
From 66e49d5b0868a9832f339056ddfd25cf4aee01ba Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michael=20M=C3=BCller?= <michael@fds-team.de>
Date: Sat, 19 Mar 2016 03:53:51 +0100
Subject: wininet: Set default HTTP port correctly when passing
INTERNET_FLAG_SECURE to InternetConnect.
---
dlls/wininet/http.c | 8 +++++--
dlls/wininet/tests/http.c | 60 ++++++++++++++++++++++++++++++++++++++++++++++-
2 files changed, 65 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 143dc75..2f8fba4 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3335,7 +3335,7 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
{
appinfo_t *hIC = session->appInfo;
http_request_t *request;
- DWORD len;
+ DWORD port, len;
TRACE("-->\n");
@@ -3364,7 +3364,11 @@ static DWORD HTTP_HttpOpenRequestW(http_session_t *session,
request->session = session;
list_add_head( &session->hdr.children, &request->hdr.entry );
- request->server = get_server(session->hostName, session->hostPort, (dwFlags & INTERNET_FLAG_SECURE) != 0, TRUE);
+ port = session->hostPort;
+ if (port == INTERNET_INVALID_PORT_NUMBER)
+ port = (session->hdr.dwFlags & INTERNET_FLAG_SECURE) ? INTERNET_DEFAULT_HTTPS_PORT : INTERNET_DEFAULT_HTTP_PORT;
+
+ request->server = get_server(session->hostName, port, (dwFlags & INTERNET_FLAG_SECURE) != 0, TRUE);
if(!request->server) {
WININET_Release(&request->hdr);
return ERROR_OUTOFMEMORY;
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 82fd10b..4e5b7fe 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -5733,7 +5733,8 @@ static void test_connection_failure(void)
static void test_default_service_port(void)
{
HINTERNET session, connect, request;
- DWORD error;
+ DWORD size, count, error;
+ char buffer[128];
BOOL ret;
session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
@@ -5753,6 +5754,63 @@ static void test_default_service_port(void)
ok(error == ERROR_INTERNET_SECURITY_CHANNEL_ERROR || error == ERROR_INTERNET_CANNOT_CONNECT,
"got %u\n", error);
+ size = sizeof(buffer) - 1;
+ count = 0;
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &count);
+ ok(ret, "HttpQueryInfo succeeded\n");
+ ok(!strcmp(buffer, "test.winehq.org:80"), "Expected test.winehg.org:80, got %s\n", buffer);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+ InternetCloseHandle(session);
+
+ session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(session != NULL, "InternetOpen failed\n");
+
+ connect = InternetConnectA(session, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER, NULL, NULL,
+ INTERNET_SERVICE_HTTP, INTERNET_FLAG_SECURE, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, INTERNET_FLAG_SECURE, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+
+ SetLastError(0xdeadbeef);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
+
+ size = sizeof(buffer) - 1;
+ count = 0;
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &count);
+ ok(ret, "HttpQueryInfo succeeded\n");
+ ok(!strcmp(buffer, "test.winehq.org"), "Expected test.winehg.org, got %s\n", buffer);
+
+ InternetCloseHandle(request);
+ InternetCloseHandle(connect);
+ InternetCloseHandle(session);
+
+ session = InternetOpenA("winetest", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
+ ok(session != NULL, "InternetOpen failed\n");
+
+ connect = InternetConnectA(session, "test.winehq.org", INTERNET_INVALID_PORT_NUMBER, NULL, NULL,
+ INTERNET_SERVICE_HTTP, INTERNET_FLAG_SECURE, 0);
+ ok(connect != NULL, "InternetConnect failed\n");
+
+ request = HttpOpenRequestA(connect, NULL, "/", NULL, NULL, NULL, 0, 0);
+ ok(request != NULL, "HttpOpenRequest failed\n");
+
+ SetLastError(0xdeadbeef);
+ ret = HttpSendRequestA(request, NULL, 0, NULL, 0);
+ ok(ret, "HttpSendRequest failed with error %u\n", GetLastError());
+
+ size = sizeof(buffer) - 1;
+ count = 0;
+ memset(buffer, 0, sizeof(buffer));
+ ret = HttpQueryInfoA(request, HTTP_QUERY_HOST | HTTP_QUERY_FLAG_REQUEST_HEADERS, buffer, &size, &count);
+ ok(ret, "HttpQueryInfo succeeded\n");
+ ok(!strcmp(buffer, "test.winehq.org:443"), "Expected test.winehg.org:443, got %s\n", buffer);
+
InternetCloseHandle(request);
InternetCloseHandle(connect);
InternetCloseHandle(session);
--
2.7.1

View File

@ -0,0 +1 @@
Fixes: [40169] Fix handling of INTERNET_INVALID_PORT_NUMBER in HttpOpenRequestW