Added patch to fix handling of Accept headers in winhttp.

This commit is contained in:
Sebastian Lackner 2016-12-21 01:02:00 +01:00
parent a6476a7726
commit 76b0d7c498
3 changed files with 132 additions and 0 deletions

View File

@ -393,6 +393,7 @@ patch_enable_all ()
enable_winex11_XEMBED="$1"
enable_winex11__NET_ACTIVE_WINDOW="$1"
enable_winex11_wglShareLists="$1"
enable_winhttp_Accept_Headers="$1"
enable_winhttp_System_Proxy_Autoconfig="$1"
enable_wininet_Cleanup="$1"
enable_wininet_InternetCrackUrlW="$1"
@ -1363,6 +1364,9 @@ patch_enable ()
winex11-wglShareLists)
enable_winex11_wglShareLists="$2"
;;
winhttp-Accept_Headers)
enable_winhttp_Accept_Headers="$2"
;;
winhttp-System_Proxy_Autoconfig)
enable_winhttp_System_Proxy_Autoconfig="$2"
;;
@ -8100,6 +8104,18 @@ if test "$enable_winex11_wglShareLists" -eq 1; then
) >> "$patchlist"
fi
# Patchset winhttp-Accept_Headers
# |
# | Modified files:
# | * dlls/winhttp/request.c, dlls/winhttp/session.c, dlls/winhttp/winhttp_private.h
# |
if test "$enable_winhttp_Accept_Headers" -eq 1; then
patch_apply winhttp-Accept_Headers/0001-winhttp-Fix-handling-of-Accept-headers.patch
(
echo '+ { "Sebastian Lackner", "winhttp: Fix handling of Accept headers.", 1 },';
) >> "$patchlist"
fi
# Patchset winhttp-System_Proxy_Autoconfig
# |
# | Modified files:

View File

@ -0,0 +1,115 @@
From 11c32d17116fc6a9ff384aee1918b476544d8f42 Mon Sep 17 00:00:00 2001
From: Sebastian Lackner <sebastian@fds-team.de>
Date: Wed, 21 Dec 2016 00:54:37 +0100
Subject: winhttp: Fix handling of Accept headers.
---
dlls/winhttp/request.c | 9 ++-------
dlls/winhttp/session.c | 26 +++-----------------------
dlls/winhttp/winhttp_private.h | 4 ++--
3 files changed, 7 insertions(+), 32 deletions(-)
diff --git a/dlls/winhttp/request.c b/dlls/winhttp/request.c
index b2b72c7..174972c 100644
--- a/dlls/winhttp/request.c
+++ b/dlls/winhttp/request.c
@@ -403,7 +403,7 @@ static BOOL delete_header( request_t *request, DWORD index )
return TRUE;
}
-static BOOL process_header( request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only )
+BOOL process_header( request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only )
{
int index;
header_t hdr;
@@ -1130,15 +1130,10 @@ static BOOL send_request( request_t *request, LPCWSTR headers, DWORD headers_len
WCHAR *req = NULL;
char *req_ascii;
int bytes_sent;
- DWORD len, i, flags;
+ DWORD len;
clear_response_headers( request );
- flags = WINHTTP_ADDREQ_FLAG_ADD|WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
- for (i = 0; i < request->num_accept_types; i++)
- {
- process_header( request, attr_accept, request->accept_types[i], flags, TRUE );
- }
if (session->agent)
process_header( request, attr_user_agent, session->agent, WINHTTP_ADDREQ_FLAG_ADD_IF_NEW, TRUE );
diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c
index 514a56d..a2db716 100644
--- a/dlls/winhttp/session.c
+++ b/dlls/winhttp/session.c
@@ -599,8 +599,6 @@ static void request_destroy( object_header_t *hdr )
heap_free( request->headers[i].value );
}
heap_free( request->headers );
- for (i = 0; i < request->num_accept_types; i++) heap_free( request->accept_types[i] );
- heap_free( request->accept_types );
for (i = 0; i < TARGET_MAX; i++)
{
for (j = 0; j < SCHEME_MAX; j++)
@@ -1023,32 +1021,14 @@ static const object_vtbl_t request_vtbl =
static BOOL store_accept_types( request_t *request, const WCHAR **accept_types )
{
+ static const WCHAR attr_accept[] = {'A','c','c','e','p','t',0};
+ static const DWORD flags = WINHTTP_ADDREQ_FLAG_ADD | WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA;
const WCHAR **types = accept_types;
- DWORD i;
if (!types) return TRUE;
while (*types)
{
- request->num_accept_types++;
- types++;
- }
- if (!request->num_accept_types) return TRUE;
- if (!(request->accept_types = heap_alloc( request->num_accept_types * sizeof(WCHAR *))))
- {
- request->num_accept_types = 0;
- return FALSE;
- }
- types = accept_types;
- for (i = 0; i < request->num_accept_types; i++)
- {
- if (!(request->accept_types[i] = strdupW( *types )))
- {
- for ( ; i > 0; --i) heap_free( request->accept_types[i - 1] );
- heap_free( request->accept_types );
- request->accept_types = NULL;
- request->num_accept_types = 0;
- return FALSE;
- }
+ process_header( request, attr_accept, *types, flags, TRUE );
types++;
}
return TRUE;
diff --git a/dlls/winhttp/winhttp_private.h b/dlls/winhttp/winhttp_private.h
index 388fc33..75ba161 100644
--- a/dlls/winhttp/winhttp_private.h
+++ b/dlls/winhttp/winhttp_private.h
@@ -207,8 +207,6 @@ typedef struct
char read_buf[8192]; /* buffer for already read but not returned data */
header_t *headers;
DWORD num_headers;
- WCHAR **accept_types;
- DWORD num_accept_types;
struct authinfo *authinfo;
struct authinfo *proxy_authinfo;
HANDLE task_wait;
@@ -303,6 +301,8 @@ void delete_domain( domain_t * ) DECLSPEC_HIDDEN;
BOOL set_server_for_hostname( connect_t *, LPCWSTR, INTERNET_PORT ) DECLSPEC_HIDDEN;
void destroy_authinfo( struct authinfo * ) DECLSPEC_HIDDEN;
+BOOL process_header( request_t *request, LPCWSTR field, LPCWSTR value, DWORD flags, BOOL request_only ) DECLSPEC_HIDDEN;
+
extern HRESULT WinHttpRequest_create( void ** ) DECLSPEC_HIDDEN;
void release_typelib( void ) DECLSPEC_HIDDEN;
--
2.9.0

View File

@ -0,0 +1 @@
Fixes: Fix handling of Accept headers in winhttp