wininet: Pass arguments as substrings to create_cookie_url.

Signed-off-by: Jacek Caban <jacek@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Jacek Caban 2016-05-16 22:42:49 +02:00 committed by Alexandre Julliard
parent b1aa9bf807
commit 51cacda534
1 changed files with 15 additions and 12 deletions

View File

@ -257,7 +257,7 @@ static BOOL cookie_match_path(cookie_container_t *container, const WCHAR *path)
return !strncmpiW(container->path, path, strlenW(container->path)); return !strncmpiW(container->path, path, strlenW(container->path));
} }
static BOOL create_cookie_url(LPCWSTR domain, LPCWSTR path, WCHAR *buf, DWORD buf_len) static BOOL create_cookie_url(substr_t domain, substr_t path, WCHAR *buf, DWORD buf_len)
{ {
static const WCHAR cookie_prefix[] = {'C','o','o','k','i','e',':'}; static const WCHAR cookie_prefix[] = {'C','o','o','k','i','e',':'};
@ -282,18 +282,16 @@ static BOOL create_cookie_url(LPCWSTR domain, LPCWSTR path, WCHAR *buf, DWORD bu
*(buf++) = '@'; *(buf++) = '@';
buf_len--; buf_len--;
len = strlenW(domain); if(domain.len >= buf_len)
if(len >= buf_len)
return FALSE; return FALSE;
memcpy(buf, domain, len*sizeof(WCHAR)); memcpy(buf, domain.str, domain.len*sizeof(WCHAR));
buf += len; buf += domain.len;
buf_len -= len; buf_len -= domain.len;
len = strlenW(path); if(path.len >= buf_len)
if(len >= buf_len)
return FALSE; return FALSE;
memcpy(buf, path, len*sizeof(WCHAR)); memcpy(buf, path.str, path.len*sizeof(WCHAR));
buf += len; buf += path.len;
*buf = 0; *buf = 0;
@ -314,8 +312,10 @@ static BOOL load_persistent_cookie(LPCWSTR domain, LPCWSTR path)
WCHAR *name, *data; WCHAR *name, *data;
FILETIME expiry, create, time; FILETIME expiry, create, time;
if (!create_cookie_url(domain, path, cookie_url, sizeof(cookie_url)/sizeof(cookie_url[0]))) if (!create_cookie_url(substrz(domain), substrz(path), cookie_url, sizeof(cookie_url)/sizeof(cookie_url[0]))) {
FIXME("Failed to create cookie URL.\n");
return FALSE; return FALSE;
}
size = 0; size = 0;
RetrieveUrlCacheEntryStreamW(cookie_url, NULL, &size, FALSE, 0); RetrieveUrlCacheEntryStreamW(cookie_url, NULL, &size, FALSE, 0);
@ -409,8 +409,11 @@ static BOOL save_persistent_cookie(cookie_container_t *container)
FILETIME time; FILETIME time;
DWORD bytes_written; DWORD bytes_written;
if (!create_cookie_url(container->domain->domain, container->path, cookie_url, sizeof(cookie_url)/sizeof(cookie_url[0]))) if (!create_cookie_url(substrz(container->domain->domain), substrz(container->path),
cookie_url, sizeof(cookie_url)/sizeof(cookie_url[0]))) {
FIXME("Failed to create cookie URL.\n");
return FALSE; return FALSE;
}
/* check if there's anything to save */ /* check if there's anything to save */
GetSystemTimeAsFileTime(&time); GetSystemTimeAsFileTime(&time);