mirror of
https://github.com/reactos/reactos.git
synced 2024-12-31 19:42:51 +00:00
[WINESYNC] wininet: Get rid of user buffer in create_cookie_url().
Signed-off-by: Serge Gautherie <winehq-git_serge_180711@gautherie.fr> Signed-off-by: Jacek Caban <jacek@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org> wine commit id d2a1c906dc4979eeabe256f77a58d67290da372d by Serge Gautherie <winehq-git_serge_180711@gautherie.fr>
This commit is contained in:
parent
e0e6d419c7
commit
9982fa3c75
2 changed files with 12 additions and 9 deletions
|
@ -151,28 +151,31 @@ static cookie_domain_t *get_cookie_domain(substr_t domain, BOOL create)
|
||||||
|
|
||||||
static WCHAR *create_cookie_url(substr_t domain, substr_t path, substr_t *ret_path)
|
static WCHAR *create_cookie_url(substr_t domain, substr_t path, substr_t *ret_path)
|
||||||
{
|
{
|
||||||
WCHAR user[UNLEN], *p, *url;
|
WCHAR *p, *url;
|
||||||
DWORD len, user_len, i;
|
DWORD len, user_len, i;
|
||||||
|
|
||||||
static const WCHAR cookie_prefix[] = {'C','o','o','k','i','e',':'};
|
static const WCHAR cookie_prefix[] = {'C','o','o','k','i','e',':'};
|
||||||
|
|
||||||
user_len = ARRAY_SIZE(user);
|
user_len = 0;
|
||||||
if(!GetUserNameW(user, &user_len))
|
if(GetUserNameW(NULL, &user_len) || GetLastError() != ERROR_INSUFFICIENT_BUFFER)
|
||||||
return FALSE;
|
return NULL;
|
||||||
user_len--;
|
|
||||||
|
|
||||||
|
/* user_len already accounts for terminating NULL */
|
||||||
len = ARRAY_SIZE(cookie_prefix) + user_len + 1 /* @ */ + domain.len + path.len;
|
len = ARRAY_SIZE(cookie_prefix) + user_len + 1 /* @ */ + domain.len + path.len;
|
||||||
url = heap_alloc((len+1) * sizeof(WCHAR));
|
url = heap_alloc(len * sizeof(WCHAR));
|
||||||
if(!url)
|
if(!url)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
memcpy(url, cookie_prefix, sizeof(cookie_prefix));
|
memcpy(url, cookie_prefix, sizeof(cookie_prefix));
|
||||||
p = url + ARRAY_SIZE(cookie_prefix);
|
p = url + ARRAY_SIZE(cookie_prefix);
|
||||||
|
|
||||||
memcpy(p, user, user_len*sizeof(WCHAR));
|
if(!GetUserNameW(p, &user_len)) {
|
||||||
|
heap_free(url);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
p += user_len;
|
p += user_len;
|
||||||
|
|
||||||
*p++ = '@';
|
*(p - 1) = '@';
|
||||||
|
|
||||||
memcpy(p, domain.str, domain.len*sizeof(WCHAR));
|
memcpy(p, domain.str, domain.len*sizeof(WCHAR));
|
||||||
p += domain.len;
|
p += domain.len;
|
||||||
|
|
|
@ -5,4 +5,4 @@ files:
|
||||||
include/wininet.h: sdk/include/psdk/wininet.h
|
include/wininet.h: sdk/include/psdk/wininet.h
|
||||||
include/winineti.h: sdk/include/psdk/winineti.h
|
include/winineti.h: sdk/include/psdk/winineti.h
|
||||||
tags:
|
tags:
|
||||||
wine: ccd6b205fa99360e7437f1c5bc63e0075f8e6760
|
wine: d2a1c906dc4979eeabe256f77a58d67290da372d
|
||||||
|
|
Loading…
Reference in a new issue