Module: wine Branch: master Commit: 3413d01764b435a708d67b5a8a00d973f16e9720 URL: http://source.winehq.org/git/wine.git/?a=commit;h=3413d01764b435a708d67b5a8a...
Author: Jacek Caban jacek@codeweavers.com Date: Tue May 17 19:18:32 2016 +0200
wininet: Pass host name as substring to get_server.
Signed-off-by: Jacek Caban jacek@codeweavers.com Signed-off-by: Alexandre Julliard julliard@winehq.org
---
dlls/wininet/http.c | 18 +++++++++--------- dlls/wininet/internet.c | 10 +--------- dlls/wininet/internet.h | 2 +- 3 files changed, 11 insertions(+), 19 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c index daaf3aa..0f155cf 100644 --- a/dlls/wininet/http.c +++ b/dlls/wininet/http.c @@ -265,7 +265,7 @@ static BOOL process_host_port(server_t *server) return TRUE; }
-server_t *get_server(const WCHAR *name, INTERNET_PORT port, BOOL is_https, BOOL do_create) +server_t *get_server(substr_t name, INTERNET_PORT port, BOOL is_https, BOOL do_create) { server_t *iter, *server = NULL;
@@ -275,7 +275,8 @@ server_t *get_server(const WCHAR *name, INTERNET_PORT port, BOOL is_https, BOOL EnterCriticalSection(&connection_pool_cs);
LIST_FOR_EACH_ENTRY(iter, &connection_pool, server_t, entry) { - if(iter->port == port && !strcmpW(iter->name, name) && iter->is_https == is_https) { + if(iter->port == port && name.len == strlenW(iter->name) && !strncmpW(iter->name, name.str, name.len) + && iter->is_https == is_https) { server = iter; server_addref(server); break; @@ -289,7 +290,7 @@ server_t *get_server(const WCHAR *name, INTERNET_PORT port, BOOL is_https, BOOL server->port = port; server->is_https = is_https; list_init(&server->conn_pool); - server->name = heap_strdupW(name); + server->name = heap_strndupW(name.str, name.len); if(server->name && process_host_port(server)) { list_add_head(&connection_pool, &server->entry); }else { @@ -1788,7 +1789,6 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req static const WCHAR protoHttp[] = { 'h','t','t','p',0 }; static const WCHAR szHttp[] = { 'h','t','t','p',':','/','/',0 }; static const WCHAR szFormat[] = { 'h','t','t','p',':','/','/','%','s',0 }; - WCHAR buf[INTERNET_MAX_HOST_NAME_LENGTH]; WCHAR protoProxy[INTERNET_MAX_URL_LENGTH]; DWORD protoProxyLen = INTERNET_MAX_URL_LENGTH; WCHAR proxy[INTERNET_MAX_URL_LENGTH]; @@ -1799,8 +1799,7 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req
memset( &UrlComponents, 0, sizeof UrlComponents ); UrlComponents.dwStructSize = sizeof UrlComponents; - UrlComponents.lpszHostName = buf; - UrlComponents.dwHostNameLength = INTERNET_MAX_HOST_NAME_LENGTH; + UrlComponents.dwHostNameLength = 1;
if (!INTERNET_FindProxyForProtocol(hIC->proxy, protoHttp, protoProxy, &protoProxyLen)) return FALSE; @@ -1821,7 +1820,8 @@ static BOOL HTTP_DealWithProxy(appinfo_t *hIC, http_session_t *session, http_req if (is_https && UrlComponents.nPort == INTERNET_INVALID_PORT_NUMBER) UrlComponents.nPort = INTERNET_DEFAULT_HTTPS_PORT;
- new_server = get_server(UrlComponents.lpszHostName, UrlComponents.nPort, is_https, TRUE); + new_server = get_server(substr(UrlComponents.lpszHostName, UrlComponents.dwHostNameLength), + UrlComponents.nPort, is_https, TRUE); if(!new_server) return FALSE;
@@ -3391,7 +3391,7 @@ 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); + request->server = get_server(substrz(session->hostName), session->hostPort, (dwFlags & INTERNET_FLAG_SECURE) != 0, TRUE); if(!request->server) { WININET_Release(&request->hdr); return ERROR_OUTOFMEMORY; @@ -4204,7 +4204,7 @@ static DWORD HTTP_HandleRedirect(http_request_t *request, LPCWSTR lpszUrl) if(strcmpiW(request->server->name, hostName) || request->server->port != urlComponents.nPort) { server_t *new_server;
- new_server = get_server(hostName, urlComponents.nPort, urlComponents.nScheme == INTERNET_SCHEME_HTTPS, TRUE); + new_server = get_server(substrz(hostName), urlComponents.nPort, urlComponents.nScheme == INTERNET_SCHEME_HTTPS, TRUE); server_release(request->server); request->server = new_server; } diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c index 78bea7c..fdad378 100644 --- a/dlls/wininet/internet.c +++ b/dlls/wininet/internet.c @@ -4496,7 +4496,6 @@ BOOL WINAPI InternetGetSecurityInfoByURLW(LPCWSTR lpszURL, PCCERT_CHAIN_CONTEXT { URL_COMPONENTSW url = {sizeof(url)}; server_t *server; - WCHAR *hostname; BOOL res;
TRACE("(%s %p %p)\n", debugstr_w(lpszURL), ppCertChain, pdwSecureFlags); @@ -4508,14 +4507,7 @@ BOOL WINAPI InternetGetSecurityInfoByURLW(LPCWSTR lpszURL, PCCERT_CHAIN_CONTEXT return FALSE; }
- hostname = heap_strndupW(url.lpszHostName, url.dwHostNameLength); - if(!hostname) { - SetLastError(ERROR_OUTOFMEMORY); - return FALSE; - } - - server = get_server(hostname, url.nPort, TRUE, FALSE); - heap_free(hostname); + server = get_server(substr(url.lpszHostName, url.dwHostNameLength), url.nPort, TRUE, FALSE); if(!server) { SetLastError(ERROR_INTERNET_ITEM_NOT_FOUND); return FALSE; diff --git a/dlls/wininet/internet.h b/dlls/wininet/internet.h index 20ee999..8cd1a8e 100644 --- a/dlls/wininet/internet.h +++ b/dlls/wininet/internet.h @@ -467,7 +467,7 @@ DWORD NETCON_set_timeout(netconn_t *connection, BOOL send, DWORD value) DECLSPEC int sock_send(int fd, const void *msg, size_t len, int flags) DECLSPEC_HIDDEN; int sock_recv(int fd, void *msg, size_t len, int flags) DECLSPEC_HIDDEN;
-server_t *get_server(const WCHAR*,INTERNET_PORT,BOOL,BOOL) DECLSPEC_HIDDEN; +server_t *get_server(substr_t,INTERNET_PORT,BOOL,BOOL) DECLSPEC_HIDDEN;
DWORD create_req_file(const WCHAR*,req_file_t**) DECLSPEC_HIDDEN; void req_file_release(req_file_t*) DECLSPEC_HIDDEN;