Roy Shea : wininet: Added check of dwStructSize required by Windows in calls to InternetCrackUrlA .
Alexandre Julliard
julliard at winehq.org
Wed Dec 5 06:56:38 CST 2007
Module: wine
Branch: master
Commit: 91d07f699590d0a64f0f72e49e438db17f699c30
URL: http://source.winehq.org/git/wine.git/?a=commit;h=91d07f699590d0a64f0f72e49e438db17f699c30
Author: Roy Shea <roy at cs.hmc.edu>
Date: Tue Dec 4 14:55:18 2007 -0800
wininet: Added check of dwStructSize required by Windows in calls to InternetCrackUrlA.
---
dlls/wininet/internet.c | 4 +++-
dlls/wininet/tests/url.c | 19 +++++++++++++++++++
2 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/dlls/wininet/internet.c b/dlls/wininet/internet.c
index 5848ea1..cf4e9bf 100644
--- a/dlls/wininet/internet.c
+++ b/dlls/wininet/internet.c
@@ -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)
diff --git a/dlls/wininet/tests/url.c b/dlls/wininet/tests/url.c
index 8469072..e7c4288 100644
--- a/dlls/wininet/tests/url.c
+++ b/dlls/wininet/tests/url.c
@@ -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)
More information about the wine-cvs
mailing list