Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
0055cfed
Commit
0055cfed
authored
Jul 19, 2009
by
Jacek Caban
Committed by
Alexandre Julliard
Jul 20, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Code clean up by using heap_strdup* functions.
parent
f8600c70
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
74 deletions
+24
-74
cookie.c
dlls/wininet/cookie.c
+24
-74
No files found.
dlls/wininet/cookie.c
View file @
0055cfed
...
...
@@ -95,17 +95,8 @@ static cookie *COOKIE_addCookie(cookie_domain *domain, LPCWSTR name, LPCWSTR dat
newCookie
->
lpCookieName
=
NULL
;
newCookie
->
lpCookieData
=
NULL
;
newCookie
->
expiry
=
expiry
;
if
(
name
)
{
newCookie
->
lpCookieName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
name
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
newCookie
->
lpCookieName
,
name
);
}
if
(
data
)
{
newCookie
->
lpCookieData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
data
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
newCookie
->
lpCookieData
,
data
);
}
newCookie
->
lpCookieName
=
heap_strdupW
(
name
);
newCookie
->
lpCookieData
=
heap_strdupW
(
data
);
TRACE
(
"added cookie %p (data is %s)
\n
"
,
newCookie
,
debugstr_w
(
data
)
);
...
...
@@ -160,17 +151,8 @@ static cookie_domain *COOKIE_addDomain(LPCWSTR domain, LPCWSTR path)
list_init
(
&
newDomain
->
cookie_list
);
newDomain
->
lpCookieDomain
=
NULL
;
newDomain
->
lpCookiePath
=
NULL
;
if
(
domain
)
{
newDomain
->
lpCookieDomain
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
domain
)
+
1
)
*
sizeof
(
WCHAR
));
strcpyW
(
newDomain
->
lpCookieDomain
,
domain
);
}
if
(
path
)
{
newDomain
->
lpCookiePath
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
path
)
+
1
)
*
sizeof
(
WCHAR
));
lstrcpyW
(
newDomain
->
lpCookiePath
,
path
);
}
newDomain
->
lpCookieDomain
=
heap_strdupW
(
domain
);
newDomain
->
lpCookiePath
=
heap_strdupW
(
path
);
list_add_tail
(
&
domain_list
,
&
newDomain
->
entry
);
...
...
@@ -398,27 +380,16 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
LPSTR
lpCookieData
,
LPDWORD
lpdwSize
)
{
DWORD
len
;
LPWSTR
szCookieData
=
NULL
,
szUrl
=
NULL
,
szCookieName
=
NULL
;
LPWSTR
szCookieData
=
NULL
,
url
,
name
;
BOOL
r
;
TRACE
(
"(%s,%s,%p)
\n
"
,
debugstr_a
(
lpszUrl
),
debugstr_a
(
lpszCookieName
),
lpCookieData
);
if
(
lpszUrl
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszUrl
,
-
1
,
NULL
,
0
);
szUrl
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszUrl
,
-
1
,
szUrl
,
len
);
}
if
(
lpszCookieName
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszCookieName
,
-
1
,
NULL
,
0
);
szCookieName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszCookieName
,
-
1
,
szCookieName
,
len
);
}
url
=
heap_strdupAtoW
(
lpszUrl
);
name
=
heap_strdupAtoW
(
lpszCookieName
);
r
=
InternetGetCookieW
(
szUrl
,
szCookieN
ame
,
NULL
,
&
len
);
r
=
InternetGetCookieW
(
url
,
n
ame
,
NULL
,
&
len
);
if
(
r
)
{
szCookieData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
...
...
@@ -428,7 +399,7 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
}
else
{
r
=
InternetGetCookieW
(
szUrl
,
szCookieN
ame
,
szCookieData
,
&
len
);
r
=
InternetGetCookieW
(
url
,
n
ame
,
szCookieData
,
&
len
);
*
lpdwSize
=
WideCharToMultiByte
(
CP_ACP
,
0
,
szCookieData
,
len
,
lpCookieData
,
*
lpdwSize
,
NULL
,
NULL
);
...
...
@@ -436,8 +407,8 @@ BOOL WINAPI InternetGetCookieA(LPCSTR lpszUrl, LPCSTR lpszCookieName,
}
HeapFree
(
GetProcessHeap
(),
0
,
szCookieData
);
HeapFree
(
GetProcessHeap
(),
0
,
szCookieN
ame
);
HeapFree
(
GetProcessHeap
(),
0
,
szU
rl
);
HeapFree
(
GetProcessHeap
(),
0
,
n
ame
);
HeapFree
(
GetProcessHeap
(),
0
,
u
rl
);
return
r
;
}
...
...
@@ -452,14 +423,13 @@ static BOOL set_cookie(LPCWSTR domain, LPCWSTR path, LPCWSTR cookie_name, LPCWST
FILETIME
expiry
;
BOOL
expired
=
FALSE
;
value
=
data
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
strlenW
(
cookie_data
)
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
data
==
NULL
)
value
=
data
=
heap_strdupW
(
cookie_data
);
if
(
!
data
)
{
ERR
(
"could not allocate %zu bytes for the cookie data buffer
\n
"
,
(
strlenW
(
cookie_data
)
+
1
)
*
sizeof
(
WCHAR
));
return
FALSE
;
}
strcpyW
(
data
,
cookie_data
);
memset
(
&
expiry
,
0
,
sizeof
(
expiry
));
/* lots of information can be parsed out of the cookie value */
...
...
@@ -605,21 +575,19 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
if
(
!
lpszCookieName
)
{
unsigned
int
len
;
WCHAR
*
cookie
,
*
data
;
len
=
strlen
W
(
lpCookieData
);
if
(
!
(
cookie
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
len
+
1
)
*
sizeof
(
WCHAR
)))
)
cookie
=
heap_strdup
W
(
lpCookieData
);
if
(
!
cookie
)
{
SetLastError
(
ERROR_OUTOFMEMORY
);
return
FALSE
;
}
strcpyW
(
cookie
,
lpCookieData
);
/* some apps (or is it us??) try to add a cookie with no cookie name, but
* the cookie data in the form of name[=data].
*/
if
(
!
(
data
=
strchrW
(
cookie
,
'='
)))
data
=
cookie
+
len
;
if
(
!
(
data
=
strchrW
(
cookie
,
'='
)))
data
=
cookie
+
strlenW
(
cookie
)
;
else
*
data
++
=
0
;
ret
=
set_cookie
(
hostName
,
path
,
cookie
,
data
);
...
...
@@ -644,39 +612,21 @@ BOOL WINAPI InternetSetCookieW(LPCWSTR lpszUrl, LPCWSTR lpszCookieName,
BOOL
WINAPI
InternetSetCookieA
(
LPCSTR
lpszUrl
,
LPCSTR
lpszCookieName
,
LPCSTR
lpCookieData
)
{
DWORD
len
;
LPWSTR
szCookieData
=
NULL
,
szUrl
=
NULL
,
szCookieName
=
NULL
;
LPWSTR
data
,
url
,
name
;
BOOL
r
;
TRACE
(
"(%s,%s,%s)
\n
"
,
debugstr_a
(
lpszUrl
),
debugstr_a
(
lpszCookieName
),
debugstr_a
(
lpCookieData
));
if
(
lpszUrl
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszUrl
,
-
1
,
NULL
,
0
);
szUrl
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszUrl
,
-
1
,
szUrl
,
len
);
}
url
=
heap_strdupAtoW
(
lpszUrl
);
name
=
heap_strdupAtoW
(
lpszCookieName
);
data
=
heap_strdupAtoW
(
lpCookieData
);
if
(
lpszCookieName
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszCookieName
,
-
1
,
NULL
,
0
);
szCookieName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszCookieName
,
-
1
,
szCookieName
,
len
);
}
r
=
InternetSetCookieW
(
url
,
name
,
data
);
if
(
lpCookieData
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
lpCookieData
,
-
1
,
NULL
,
0
);
szCookieData
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
)
);
MultiByteToWideChar
(
CP_ACP
,
0
,
lpCookieData
,
-
1
,
szCookieData
,
len
);
}
r
=
InternetSetCookieW
(
szUrl
,
szCookieName
,
szCookieData
);
HeapFree
(
GetProcessHeap
(),
0
,
szCookieData
);
HeapFree
(
GetProcessHeap
(),
0
,
szCookieName
);
HeapFree
(
GetProcessHeap
(),
0
,
szUrl
);
HeapFree
(
GetProcessHeap
(),
0
,
data
);
HeapFree
(
GetProcessHeap
(),
0
,
name
);
HeapFree
(
GetProcessHeap
(),
0
,
url
);
return
r
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment