From f547592bd2173eec9fcb6ef27363a3bd83348f01 Mon Sep 17 00:00:00 2001 From: Haoyang Chen Date: Wed, 7 Apr 2021 18:01:38 +0800 Subject: [PATCH] winhttp: Invalid url decomposition should return failure when it fails. Signed-off-by: Haoyang Chen Signed-off-by: Hans Leidekker Signed-off-by: Alexandre Julliard --- dlls/winhttp/session.c | 5 +++-- dlls/winhttp/tests/winhttp.c | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/dlls/winhttp/session.c b/dlls/winhttp/session.c index 319066db55b..f052c3c569c 100644 --- a/dlls/winhttp/session.c +++ b/dlls/winhttp/session.c @@ -1854,7 +1854,7 @@ static BOOL run_script( char *script, DWORD size, const WCHAR *url, WINHTTP_PROX uc.dwStructSize = sizeof(uc); uc.dwHostNameLength = -1; - if (WinHttpCrackUrl( url, 0, 0, &uc )) + if ((ret = WinHttpCrackUrl( url, 0, 0, &uc ))) { char *hostnameA = strdupWA_sized( uc.lpszHostName, uc.dwHostNameLength ); @@ -1868,7 +1868,8 @@ static BOOL run_script( char *script, DWORD size, const WCHAR *url, WINHTTP_PROX heap_free( hostnameA ); } heap_free( urlA ); - return InternetDeInitializeAutoProxyDll( NULL, 0 ); + InternetDeInitializeAutoProxyDll( NULL, 0 ); + return ret; } /*********************************************************************** diff --git a/dlls/winhttp/tests/winhttp.c b/dlls/winhttp/tests/winhttp.c index 6a61a23ec02..56f35252615 100644 --- a/dlls/winhttp/tests/winhttp.c +++ b/dlls/winhttp/tests/winhttp.c @@ -4974,6 +4974,9 @@ static void test_WinHttpGetProxyForUrl(void) trace("Proxy.ProxyBypass=%s\n", wine_dbgstr_w(info.lpszProxyBypass)); GlobalFree( info.lpszProxy ); GlobalFree( info.lpszProxyBypass ); + + ret = WinHttpGetProxyForUrl( session, L"http:", &options, &info ); + ok( !ret, "expected failure\n" ); } options.dwFlags = WINHTTP_AUTOPROXY_CONFIG_URL; @@ -4990,6 +4993,13 @@ static void test_WinHttpGetProxyForUrl(void) GlobalFree( info.lpszProxy ); GlobalFree( info.lpszProxyBypass ); } + + options.dwFlags = WINHTTP_AUTOPROXY_AUTO_DETECT; + options.dwAutoDetectFlags = WINHTTP_AUTO_DETECT_TYPE_DHCP|WINHTTP_AUTO_DETECT_TYPE_DNS_A; + + ret = WinHttpGetProxyForUrl( session, L"http:", &options, &info ); + ok( !ret, "expected failure\n" ); + WinHttpCloseHandle( session ); }