wininet: Added check of dwStructSize required by Windows in calls to InternetCrackUrlA.

This commit is contained in:
Roy Shea 2007-12-04 14:55:18 -08:00 committed by Alexandre Julliard
parent 7903d7f3f4
commit 91d07f6995
2 changed files with 22 additions and 1 deletions

View File

@ -1069,7 +1069,8 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
TRACE("(%s %u %x %p)\n", debugstr_a(lpszUrl), dwUrlLength, dwFlags, lpUrlComponents);
if (!lpszUrl || !*lpszUrl)
if (!lpszUrl || !*lpszUrl || !lpUrlComponents ||
lpUrlComponents->dwStructSize != sizeof(URL_COMPONENTSA))
{
INTERNET_SetLastError(ERROR_INVALID_PARAMETER);
return FALSE;
@ -1087,6 +1088,7 @@ BOOL WINAPI InternetCrackUrlA(LPCSTR lpszUrl, DWORD dwUrlLength, DWORD dwFlags,
MultiByteToWideChar(CP_ACP,0,lpszUrl,dwUrlLength,lpwszUrl,nLength);
memset(&UCW,0,sizeof(UCW));
UCW.dwStructSize = sizeof(URL_COMPONENTSW);
if(lpUrlComponents->dwHostNameLength!=0)
UCW.dwHostNameLength= lpUrlComponents->dwHostNameLength;
if(lpUrlComponents->dwUserNameLength!=0)

View File

@ -239,6 +239,25 @@ static void InternetCrackUrl_test(void)
GLE = GetLastError();
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
/* Invalid Call: must set size of components structure (Windows only
* inforces this on the InternetCrackUrlA version of the call) */
copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024);
SetLastError(0xdeadbeef);
urlComponents.dwStructSize = 0;
ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
/* Invalid Call: size of dwStructSize must be one of the "standard" sizes
* of the URL_COMPONENTS structure (Windows only inforces this on the
* InternetCrackUrlA version of the call) */
copy_compsA(&urlSrc, &urlComponents, 0, 1024, 1024, 1024, 2048, 1024);
SetLastError(0xdeadbeef);
urlComponents.dwStructSize = sizeof(urlComponents) + 1;
ret = InternetCrackUrlA(TEST_URL, 0, 0, &urlComponents);
ok(ret == FALSE, "Expected InternetCrackUrl to fail\n");
ok(GLE != 0xdeadbeef && GLE != ERROR_SUCCESS, "Expected GLE to represent a failure\n");
}
static void InternetCrackUrlW_test(void)