From 51cacda534411bedf8a10b126181e5087f9908e1 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 16 May 2016 22:42:49 +0200 Subject: [PATCH] wininet: Pass arguments as substrings to create_cookie_url. Signed-off-by: Jacek Caban Signed-off-by: Alexandre Julliard --- dlls/wininet/cookie.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/dlls/wininet/cookie.c b/dlls/wininet/cookie.c index 2a3efa604f..4e885d75e0 100644 --- a/dlls/wininet/cookie.c +++ b/dlls/wininet/cookie.c @@ -257,7 +257,7 @@ static BOOL cookie_match_path(cookie_container_t *container, const WCHAR *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',':'}; @@ -282,18 +282,16 @@ static BOOL create_cookie_url(LPCWSTR domain, LPCWSTR path, WCHAR *buf, DWORD bu *(buf++) = '@'; buf_len--; - len = strlenW(domain); - if(len >= buf_len) + if(domain.len >= buf_len) return FALSE; - memcpy(buf, domain, len*sizeof(WCHAR)); - buf += len; - buf_len -= len; + memcpy(buf, domain.str, domain.len*sizeof(WCHAR)); + buf += domain.len; + buf_len -= domain.len; - len = strlenW(path); - if(len >= buf_len) + if(path.len >= buf_len) return FALSE; - memcpy(buf, path, len*sizeof(WCHAR)); - buf += len; + memcpy(buf, path.str, path.len*sizeof(WCHAR)); + buf += path.len; *buf = 0; @@ -314,8 +312,10 @@ static BOOL load_persistent_cookie(LPCWSTR domain, LPCWSTR path) WCHAR *name, *data; 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; + } size = 0; RetrieveUrlCacheEntryStreamW(cookie_url, NULL, &size, FALSE, 0); @@ -409,8 +409,11 @@ static BOOL save_persistent_cookie(cookie_container_t *container) FILETIME time; 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; + } /* check if there's anything to save */ GetSystemTimeAsFileTime(&time);