Commit 36649d08 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

jsproxy: Fix parameters validation in InternetInitializeAutoProxyDll.

parent a1e0a029
...@@ -179,20 +179,15 @@ BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile ...@@ -179,20 +179,15 @@ BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile
if (buffer && buffer->dwStructSize == sizeof(*buffer) && buffer->lpszScriptBuffer) if (buffer && buffer->dwStructSize == sizeof(*buffer) && buffer->lpszScriptBuffer)
{ {
DWORD i, len = 0; if (!buffer->dwScriptBufferSize)
for (i = 0; i < buffer->dwScriptBufferSize; i++)
{
if (!buffer->lpszScriptBuffer[i]) break;
len++;
}
if (len == buffer->dwScriptBufferSize)
{ {
SetLastError( ERROR_INVALID_PARAMETER ); SetLastError( ERROR_INVALID_PARAMETER );
LeaveCriticalSection( &cs_jsproxy ); LeaveCriticalSection( &cs_jsproxy );
return FALSE; return FALSE;
} }
heap_free( global_script->text ); heap_free( global_script->text );
if ((global_script->text = strdupAW( buffer->lpszScriptBuffer, len ))) ret = TRUE; if ((global_script->text = strdupAW( buffer->lpszScriptBuffer,
buffer->dwScriptBufferSize ))) ret = TRUE;
} }
else else
{ {
......
...@@ -24,6 +24,8 @@ ...@@ -24,6 +24,8 @@
#include "wine/test.h" #include "wine/test.h"
static BOOL old_jsproxy;
static BOOL (WINAPI *pInternetInitializeAutoProxyDll) static BOOL (WINAPI *pInternetInitializeAutoProxyDll)
(DWORD, LPSTR, LPSTR, AutoProxyHelperFunctions *, AUTO_PROXY_SCRIPT_BUFFER *); (DWORD, LPSTR, LPSTR, AutoProxyHelperFunctions *, AUTO_PROXY_SCRIPT_BUFFER *);
static BOOL (WINAPI *pInternetDeInitializeAutoProxyDll)(LPSTR, DWORD); static BOOL (WINAPI *pInternetDeInitializeAutoProxyDll)(LPSTR, DWORD);
...@@ -34,6 +36,7 @@ static void test_InternetInitializeAutoProxyDll(void) ...@@ -34,6 +36,7 @@ static void test_InternetInitializeAutoProxyDll(void)
const char url[] = "http://localhost"; const char url[] = "http://localhost";
char script[] = "function FindProxyForURL(url, host) {return \"DIRECT\";}\0test"; char script[] = "function FindProxyForURL(url, host) {return \"DIRECT\";}\0test";
char script2[] = "function FindProxyForURL(url, host) {return \"PROXY 10.0.0.1:8080\";}\0test"; char script2[] = "function FindProxyForURL(url, host) {return \"PROXY 10.0.0.1:8080\";}\0test";
char script3[] = "function FindProxyForURL(url, host) {return \"DIRECT\";}";
char *proxy, host[] = "localhost"; char *proxy, host[] = "localhost";
AUTO_PROXY_SCRIPT_BUFFER buf; AUTO_PROXY_SCRIPT_BUFFER buf;
DWORD err, len; DWORD err, len;
...@@ -76,6 +79,16 @@ static void test_InternetInitializeAutoProxyDll(void) ...@@ -76,6 +79,16 @@ static void test_InternetInitializeAutoProxyDll(void)
ok( !strcmp( proxy, "PROXY 10.0.0.1:8080" ), "got \"%s\"\n", proxy ); ok( !strcmp( proxy, "PROXY 10.0.0.1:8080" ), "got \"%s\"\n", proxy );
GlobalFree( proxy ); GlobalFree( proxy );
buf.lpszScriptBuffer = script3;
buf.dwScriptBufferSize = strlen(script3);
ret = pInternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buf );
ok( ret || broken(old_jsproxy && !ret), "got %u\n", GetLastError() );
buf.dwScriptBufferSize = 1;
script3[0] = 0;
ret = pInternetInitializeAutoProxyDll( 0, NULL, NULL, NULL, &buf );
ok( ret, "got %u\n", GetLastError() );
ret = pInternetDeInitializeAutoProxyDll( NULL, 0 ); ret = pInternetDeInitializeAutoProxyDll( NULL, 0 );
ok( ret, "got %u\n", GetLastError() ); ok( ret, "got %u\n", GetLastError() );
} }
...@@ -150,6 +163,10 @@ START_TEST(jsproxy) ...@@ -150,6 +163,10 @@ START_TEST(jsproxy)
return; return;
} }
old_jsproxy = !GetProcAddress( module, "InternetGetProxyInfoEx" );
if (old_jsproxy)
trace( "InternetGetProxyInfoEx not available\n" );
test_InternetInitializeAutoProxyDll(); test_InternetInitializeAutoProxyDll();
test_InternetGetProxyInfo(); test_InternetGetProxyInfo();
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment