Commit 91d07f69 authored by Roy Shea's avatar Roy Shea Committed by Alexandre Julliard

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

parent 7903d7f3
......@@ -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)
......
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