Jacek Caban : wininet: Set last error for invalid URL argument.

Alexandre Julliard julliard at winehq.org
Tue Sep 4 12:38:38 CDT 2012


Module: wine
Branch: master
Commit: c4c3ff47e7ad1ae66cde22b0e479cabbaa019e35
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=c4c3ff47e7ad1ae66cde22b0e479cabbaa019e35

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Sep  4 17:08:06 2012 +0200

wininet: Set last error for invalid URL argument.

---

 dlls/wininet/cookie.c         |    5 +++-
 dlls/wininet/tests/internet.c |   45 ++++++++++++++++++++++++++++++++++++----
 2 files changed, 44 insertions(+), 6 deletions(-)

diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c
index 6f9caad..8552548 100644
--- a/dlls/wininet/cookie.c
+++ b/dlls/wininet/cookie.c
@@ -360,7 +360,10 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
 
     host[0] = 0;
     ret = COOKIE_crackUrlSimple(lpszUrl, host, sizeof(host)/sizeof(host[0]), path, sizeof(path)/sizeof(path[0]));
-    if (!ret || !host[0]) return FALSE;
+    if (!ret || !host[0]) {
+        SetLastError(ERROR_INVALID_PARAMETER);
+        return FALSE;
+    }
 
     return get_cookie(host, path, lpCookieData, lpdwSize);
 }
diff --git a/dlls/wininet/tests/internet.c b/dlls/wininet/tests/internet.c
index f2ea04f..a0b6466 100644
--- a/dlls/wininet/tests/internet.c
+++ b/dlls/wininet/tests/internet.c
@@ -40,6 +40,8 @@ static BOOL (WINAPI *pInternetTimeToSystemTimeW)(LPCWSTR ,SYSTEMTIME *,DWORD);
 static BOOL (WINAPI *pIsDomainLegalCookieDomainW)(LPCWSTR, LPCWSTR);
 static DWORD (WINAPI *pPrivacyGetZonePreferenceW)(DWORD, DWORD, LPDWORD, LPWSTR, LPDWORD);
 static DWORD (WINAPI *pPrivacySetZonePreferenceW)(DWORD, DWORD, DWORD, LPCWSTR);
+static BOOL (WINAPI *pInternetGetCookieExA)(LPCSTR,LPCSTR,LPSTR,LPDWORD,DWORD,LPVOID);
+static BOOL (WINAPI *pInternetGetCookieExW)(LPCWSTR,LPCWSTR,LPWSTR,LPDWORD,DWORD,LPVOID);
 
 /* ############################### */
 
@@ -471,6 +473,36 @@ static void test_complicated_cookie(void)
   ok(strstr(buffer,"O=P")==NULL,"O=P present\n");
 }
 
+static void test_cookie_url(void)
+{
+    WCHAR bufw[512];
+    char buf[512];
+    DWORD len;
+    BOOL res;
+
+    static const WCHAR about_blankW[] = {'a','b','o','u','t',':','b','l','a','n','k',0};
+
+    len = sizeof(buf);
+    res = InternetGetCookieA("about:blank", NULL, buf, &len);
+    ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
+       "InternetGetCookeA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+
+    len = sizeof(bufw)/sizeof(*bufw);
+    res = InternetGetCookieW(about_blankW, NULL, bufw, &len);
+    ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
+       "InternetGetCookeW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+
+    len = sizeof(buf);
+    res = pInternetGetCookieExA("about:blank", NULL, buf, &len, 0, NULL);
+    ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
+       "InternetGetCookeExA failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+
+    len = sizeof(bufw)/sizeof(*bufw);
+    res = pInternetGetCookieExW(about_blankW, NULL, bufw, &len, 0, NULL);
+    ok(!res && GetLastError() == ERROR_INVALID_PARAMETER,
+       "InternetGetCookeExW failed: %u, expected ERROR_INVALID_PARAMETER\n", GetLastError());
+}
+
 static void test_null(void)
 {
   HINTERNET hi, hc;
@@ -1381,11 +1413,6 @@ START_TEST(internet)
     HMODULE hdll;
     hdll = GetModuleHandleA("wininet.dll");
 
-    if(!GetProcAddress(hdll, "InternetGetCookieExW")) {
-        win_skip("Too old IE (older than 6.0)\n");
-        return;
-    }
-
     pCreateUrlCacheContainerA = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerA");
     pCreateUrlCacheContainerW = (void*)GetProcAddress(hdll, "CreateUrlCacheContainerW");
     pInternetTimeFromSystemTimeA = (void*)GetProcAddress(hdll, "InternetTimeFromSystemTimeA");
@@ -1395,11 +1422,19 @@ START_TEST(internet)
     pIsDomainLegalCookieDomainW = (void*)GetProcAddress(hdll, (LPCSTR)117);
     pPrivacyGetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacyGetZonePreferenceW");
     pPrivacySetZonePreferenceW = (void*)GetProcAddress(hdll, "PrivacySetZonePreferenceW");
+    pInternetGetCookieExA = (void*)GetProcAddress(hdll, "InternetGetCookieExA");
+    pInternetGetCookieExW = (void*)GetProcAddress(hdll, "InternetGetCookieExW");
+
+    if(!pInternetGetCookieExW) {
+        win_skip("Too old IE (older than 6.0)\n");
+        return;
+    }
 
     test_InternetCanonicalizeUrlA();
     test_InternetQueryOptionA();
     test_get_cookie();
     test_complicated_cookie();
+    test_cookie_url();
     test_version();
     test_null();
     test_Option_PerConnectionOption();




More information about the wine-cvs mailing list