Module: wine Branch: master Commit: 53faf7bda8f88d386a572db3b505cae0af8057fc URL: https://gitlab.winehq.org/wine/wine/-/commit/53faf7bda8f88d386a572db3b505cae...
Author: Piotr Caban piotr@codeweavers.com Date: Thu Feb 1 16:20:23 2024 +0100
jsproxy: Don't ignore hostname and url length in InternetGetProxyInfo.
---
dlls/jsproxy/main.c | 9 ++------- dlls/jsproxy/tests/jsproxy.c | 12 +++++++++++- 2 files changed, 13 insertions(+), 8 deletions(-)
diff --git a/dlls/jsproxy/main.c b/dlls/jsproxy/main.c index 4e69210dce3..9506b7153cf 100644 --- a/dlls/jsproxy/main.c +++ b/dlls/jsproxy/main.c @@ -576,13 +576,8 @@ BOOL WINAPI InternetGetProxyInfo( LPCSTR url, DWORD len_url, LPCSTR hostname, DW SetLastError( ERROR_CAN_NOT_COMPLETE ); goto done; } - if (hostname && len_hostname < strlen( hostname )) - { - SetLastError( ERROR_INSUFFICIENT_BUFFER ); - goto done; - } - if (!(urlW = strdupAW( url, -1 ))) goto done; - if (hostname && !(hostnameW = strdupAW( hostname, -1 ))) goto done; + if (!(urlW = strdupAW( url, len_url ))) goto done; + if (hostname && !(hostnameW = strdupAW( hostname, len_hostname ))) goto done;
TRACE( "%s\n", debugstr_w(global_script->text) ); ret = run_script( global_script->text, urlW, hostnameW, proxy, len_proxy ); diff --git a/dlls/jsproxy/tests/jsproxy.c b/dlls/jsproxy/tests/jsproxy.c index 505d1a9398a..901ffdf910e 100644 --- a/dlls/jsproxy/tests/jsproxy.c +++ b/dlls/jsproxy/tests/jsproxy.c @@ -104,7 +104,9 @@ static void test_InternetInitializeAutoProxyDll(void) static void test_InternetGetProxyInfo(void) { const char url[] = "http://localhost"; - char script[] = "function FindProxyForURL(url, host) { return "DIRECT"; }"; + char script[] = "function FindProxyForURL(url, host) { " + "if (url.substring(0, 4) === 'test') return url + ' ' + host; " + "return "DIRECT"; }"; char *proxy, host[] = "localhost"; AUTO_PROXY_SCRIPT_BUFFER buf; DWORD len, err; @@ -159,6 +161,14 @@ static void test_InternetGetProxyInfo(void) ok( len == strlen("DIRECT") + 1, "got %lu\n", len ); GlobalFree( proxy );
+ len = 0; + proxy = NULL; + ret = pInternetGetProxyInfo( "testa", 4, host, 4, &proxy, &len); + ok( ret, "got %lu\n", GetLastError() ); + ok( !strcmp( proxy, "test loca" ), "got "%s"\n", proxy ); + ok( len == 10, "got %lu\n", len ); + GlobalFree( proxy ); + ret = pInternetDeInitializeAutoProxyDll( NULL, 0 ); ok( ret, "got %lu\n", GetLastError() ); }