wininet: Added check of dwStructSize required by Windows in calls to InternetCrackUrlA.
This commit is contained in:
parent
7903d7f3f4
commit
91d07f6995
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue