Commit 1b8f7f06 authored by Robert Shearman's avatar Robert Shearman Committed by Alexandre Julliard

wininet: Fix InternetGetCookie with no matching cookies.

Return FALSE and an error of ERROR_NO_MORE_ITEMS from InternetGetCookie when there are no cookies for the specified domain. This fixes a bug in sending a blank cookie to HTTP servers.
parent e4adc073
......@@ -301,6 +301,14 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
}
}
}
if (!domain_count)
{
TRACE("no cookies found for %s\n", debugstr_w(hostName));
SetLastError(ERROR_NO_MORE_ITEMS);
return FALSE;
}
if (lpCookieData == NULL)
{
cnt += 1; /* NULL */
......@@ -309,9 +317,6 @@ BOOL WINAPI InternetGetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
return TRUE;
}
if (!domain_count)
return FALSE;
*lpdwSize = (cnt + 1)*sizeof(WCHAR);
TRACE("Returning %i (from %i domains): %s\n", cnt, domain_count,
......
......@@ -27,7 +27,7 @@
#include "wine/test.h"
void InternetQueryOptionA_test()
static void InternetQueryOptionA_test(void)
{
HINTERNET hinet,hurl;
DWORD len;
......@@ -107,7 +107,20 @@ void InternetQueryOptionA_test()
InternetCloseHandle(hinet);
}
static void test_get_cookie(void)
{
DWORD len;
BOOL ret;
SetLastError(0xdeadbeef);
ret = InternetGetCookie("http://www.example.com", NULL, NULL, &len);
ok(!ret && GetLastError() == ERROR_NO_MORE_ITEMS,
"InternetGetCookie should have failed with %s and error %ld\n",
ret ? "TRUE" : "FALSE", GetLastError());
}
START_TEST(internet)
{
InternetQueryOptionA_test();
test_get_cookie();
}
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