jsproxy: Fix parameters validation in InternetInitializeAutoProxyDll.

Signed-off-by: Piotr Caban <piotr@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Piotr Caban 2018-08-29 15:59:48 +02:00 committed by Alexandre Julliard
parent a1e0a029b0
commit 36649d083f
2 changed files with 20 additions and 8 deletions

View File

@ -179,20 +179,15 @@ BOOL WINAPI JSPROXY_InternetInitializeAutoProxyDll( DWORD version, LPSTR tmpfile
if (buffer && buffer->dwStructSize == sizeof(*buffer) && buffer->lpszScriptBuffer)
{
DWORD i, len = 0;
for (i = 0; i < buffer->dwScriptBufferSize; i++)
{
if (!buffer->lpszScriptBuffer[i]) break;
len++;
}
if (len == buffer->dwScriptBufferSize)
if (!buffer->dwScriptBufferSize)
{
SetLastError( ERROR_INVALID_PARAMETER );
LeaveCriticalSection( &cs_jsproxy );
return FALSE;
}
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
{

View File

@ -24,6 +24,8 @@
#include "wine/test.h"
static BOOL old_jsproxy;
static BOOL (WINAPI *pInternetInitializeAutoProxyDll)
(DWORD, LPSTR, LPSTR, AutoProxyHelperFunctions *, AUTO_PROXY_SCRIPT_BUFFER *);
static BOOL (WINAPI *pInternetDeInitializeAutoProxyDll)(LPSTR, DWORD);
@ -34,6 +36,7 @@ static void test_InternetInitializeAutoProxyDll(void)
const char url[] = "http://localhost";
char script[] = "function FindProxyForURL(url, host) {return \"DIRECT\";}\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";
AUTO_PROXY_SCRIPT_BUFFER buf;
DWORD err, len;
@ -76,6 +79,16 @@ static void test_InternetInitializeAutoProxyDll(void)
ok( !strcmp( proxy, "PROXY 10.0.0.1:8080" ), "got \"%s\"\n", 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 );
ok( ret, "got %u\n", GetLastError() );
}
@ -150,6 +163,10 @@ START_TEST(jsproxy)
return;
}
old_jsproxy = !GetProcAddress( module, "InternetGetProxyInfoEx" );
if (old_jsproxy)
trace( "InternetGetProxyInfoEx not available\n" );
test_InternetInitializeAutoProxyDll();
test_InternetGetProxyInfo();
}