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.
This commit is contained in:
parent
e4adc07333
commit
1b8f7f0605
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue