Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
ebe6e747
Commit
ebe6e747
authored
Nov 20, 2022
by
Alex Henrie
Committed by
Alexandre Julliard
Nov 21, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Use the wcsdup function instead of reimplementing it.
parent
7f5a7189
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
28 additions
and
38 deletions
+28
-38
cookie.c
dlls/winhttp/cookie.c
+4
-4
net.c
dlls/winhttp/net.c
+1
-1
request.c
dlls/winhttp/request.c
+13
-13
session.c
dlls/winhttp/session.c
+10
-10
winhttp_private.h
dlls/winhttp/winhttp_private.h
+0
-10
No files found.
dlls/winhttp/cookie.c
View file @
ebe6e747
...
...
@@ -54,7 +54,7 @@ static struct domain *add_domain( struct session *session, WCHAR *name )
list_init
(
&
domain
->
entry
);
list_init
(
&
domain
->
cookies
);
domain
->
name
=
strdupW
(
name
);
domain
->
name
=
wcsdup
(
name
);
list_add_tail
(
&
session
->
cookie_cache
,
&
domain
->
entry
);
TRACE
(
"%s
\n
"
,
debugstr_w
(
domain
->
name
));
...
...
@@ -135,7 +135,7 @@ static BOOL add_cookie( struct session *session, struct cookie *cookie, WCHAR *d
struct
cookie
*
old_cookie
;
struct
list
*
item
;
if
(
!
(
cookie
->
path
=
strdupW
(
path
)))
return
FALSE
;
if
(
!
(
cookie
->
path
=
wcsdup
(
path
)))
return
FALSE
;
EnterCriticalSection
(
&
session
->
cs
);
...
...
@@ -303,8 +303,8 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
len
-=
used
;
p
+=
used
;
}
if
(
!
cookie_domain
&&
!
(
cookie_domain
=
strdupW
(
request
->
connect
->
servername
)))
goto
end
;
if
(
!
cookie_path
&&
!
(
cookie_path
=
strdupW
(
request
->
path
)))
goto
end
;
if
(
!
cookie_domain
&&
!
(
cookie_domain
=
wcsdup
(
request
->
connect
->
servername
)))
goto
end
;
if
(
!
cookie_path
&&
!
(
cookie_path
=
wcsdup
(
request
->
path
)))
goto
end
;
if
((
p
=
wcsrchr
(
cookie_path
,
'/'
))
&&
p
!=
cookie_path
)
*
p
=
0
;
ret
=
add_cookie
(
session
,
cookie
,
cookie_domain
,
cookie_path
);
...
...
dlls/winhttp/net.c
View file @
ebe6e747
...
...
@@ -770,7 +770,7 @@ static struct async_resolve *create_async_resolve( const WCHAR *hostname, INTERN
return
NULL
;
}
ret
->
ref
=
1
;
ret
->
hostname
=
strdupW
(
hostname
);
ret
->
hostname
=
wcsdup
(
hostname
);
ret
->
port
=
port
;
if
(
!
(
ret
->
done
=
CreateEventW
(
NULL
,
FALSE
,
FALSE
,
NULL
)))
{
...
...
dlls/winhttp/request.c
View file @
ebe6e747
...
...
@@ -371,8 +371,8 @@ static DWORD insert_header( struct request *request, struct header *header )
if
(
!
hdrs
)
return
ERROR_OUTOFMEMORY
;
request
->
headers
=
hdrs
;
request
->
headers
[
count
-
1
].
field
=
strdupW
(
header
->
field
);
request
->
headers
[
count
-
1
].
value
=
strdupW
(
header
->
value
);
request
->
headers
[
count
-
1
].
field
=
wcsdup
(
header
->
field
);
request
->
headers
[
count
-
1
].
value
=
wcsdup
(
header
->
value
);
request
->
headers
[
count
-
1
].
is_request
=
header
->
is_request
;
request
->
num_headers
=
count
;
return
ERROR_SUCCESS
;
...
...
@@ -1562,7 +1562,7 @@ static DWORD open_connection( struct request *request )
host
->
secure
=
is_secure
;
host
->
port
=
port
;
list_init
(
&
host
->
connections
);
if
((
host
->
hostname
=
strdupW
(
connect
->
servername
)))
if
((
host
->
hostname
=
wcsdup
(
connect
->
servername
)))
{
list_add_head
(
&
connection_pool
,
&
host
->
entry
);
}
...
...
@@ -2309,7 +2309,7 @@ BOOL WINAPI WinHttpSendRequest( HINTERNET hrequest, const WCHAR *headers, DWORD
SetLastError
(
ERROR_OUTOFMEMORY
);
return
FALSE
;
}
s
->
headers
=
strdupW
(
headers
);
s
->
headers
=
wcsdup
(
headers
);
s
->
headers_len
=
headers_len
;
s
->
optional
=
optional
;
s
->
optional_len
=
optional_len
;
...
...
@@ -2344,22 +2344,22 @@ static DWORD set_credentials( struct request *request, DWORD target, DWORD schem
{
free
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
username
);
if
(
!
username
)
request
->
creds
[
TARGET_SERVER
][
scheme
].
username
=
NULL
;
else
if
(
!
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
username
=
strdupW
(
username
)))
return
ERROR_OUTOFMEMORY
;
else
if
(
!
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
username
=
wcsdup
(
username
)))
return
ERROR_OUTOFMEMORY
;
free
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
password
);
if
(
!
password
)
request
->
creds
[
TARGET_SERVER
][
scheme
].
password
=
NULL
;
else
if
(
!
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
password
=
strdupW
(
password
)))
return
ERROR_OUTOFMEMORY
;
else
if
(
!
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
password
=
wcsdup
(
password
)))
return
ERROR_OUTOFMEMORY
;
break
;
}
case
WINHTTP_AUTH_TARGET_PROXY
:
{
free
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
username
);
if
(
!
username
)
request
->
creds
[
TARGET_PROXY
][
scheme
].
username
=
NULL
;
else
if
(
!
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
username
=
strdupW
(
username
)))
return
ERROR_OUTOFMEMORY
;
else
if
(
!
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
username
=
wcsdup
(
username
)))
return
ERROR_OUTOFMEMORY
;
free
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
password
);
if
(
!
password
)
request
->
creds
[
TARGET_PROXY
][
scheme
].
password
=
NULL
;
else
if
(
!
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
password
=
strdupW
(
password
)))
return
ERROR_OUTOFMEMORY
;
else
if
(
!
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
password
=
wcsdup
(
password
)))
return
ERROR_OUTOFMEMORY
;
break
;
}
default:
...
...
@@ -2735,13 +2735,13 @@ static DWORD handle_redirect( struct request *request, DWORD status )
memcpy
(
request
->
path
,
uc
.
lpszUrlPath
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
);
request
->
path
[
len
]
=
0
;
}
else
request
->
path
=
strdupW
(
L"/"
);
else
request
->
path
=
wcsdup
(
L"/"
);
}
if
(
status
!=
HTTP_STATUS_REDIRECT_KEEP_VERB
&&
!
wcscmp
(
request
->
verb
,
L"POST"
))
{
free
(
request
->
verb
);
request
->
verb
=
strdupW
(
L"GET"
);
request
->
verb
=
wcsdup
(
L"GET"
);
request
->
optional
=
NULL
;
request
->
optional_len
=
0
;
}
...
...
@@ -4659,12 +4659,12 @@ static HRESULT WINAPI winhttp_request_SetProxy(
if
(
V_VT
(
&
proxy_server
)
==
VT_BSTR
)
{
free
(
request
->
proxy
.
lpszProxy
);
request
->
proxy
.
lpszProxy
=
strdupW
(
V_BSTR
(
&
proxy_server
)
);
request
->
proxy
.
lpszProxy
=
wcsdup
(
V_BSTR
(
&
proxy_server
)
);
}
if
(
V_VT
(
&
bypass_list
)
==
VT_BSTR
)
{
free
(
request
->
proxy
.
lpszProxyBypass
);
request
->
proxy
.
lpszProxyBypass
=
strdupW
(
V_BSTR
(
&
bypass_list
)
);
request
->
proxy
.
lpszProxyBypass
=
wcsdup
(
V_BSTR
(
&
bypass_list
)
);
}
break
;
...
...
@@ -4796,7 +4796,7 @@ static HRESULT WINAPI winhttp_request_Open(
memcpy
(
path
,
uc
.
lpszUrlPath
,
(
uc
.
dwUrlPathLength
+
uc
.
dwExtraInfoLength
)
*
sizeof
(
WCHAR
)
);
path
[
uc
.
dwUrlPathLength
+
uc
.
dwExtraInfoLength
]
=
0
;
if
(
!
(
verb
=
strdupW
(
method
)))
goto
error
;
if
(
!
(
verb
=
wcsdup
(
method
)))
goto
error
;
if
(
SUCCEEDED
(
VariantChangeType
(
&
async
,
&
async
,
0
,
VT_BOOL
))
&&
V_BOOL
(
&
async
))
request
->
async
=
TRUE
;
else
request
->
async
=
FALSE
;
...
...
dlls/winhttp/session.c
View file @
ebe6e747
...
...
@@ -322,20 +322,20 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
InitializeCriticalSection
(
&
session
->
cs
);
session
->
cs
.
DebugInfo
->
Spare
[
0
]
=
(
DWORD_PTR
)(
__FILE__
": session.cs"
);
if
(
agent
&&
!
(
session
->
agent
=
strdupW
(
agent
)))
goto
end
;
if
(
agent
&&
!
(
session
->
agent
=
wcsdup
(
agent
)))
goto
end
;
if
(
access
==
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
)
{
WINHTTP_PROXY_INFO
info
;
WinHttpGetDefaultProxyConfiguration
(
&
info
);
session
->
access
=
info
.
dwAccessType
;
if
(
info
.
lpszProxy
&&
!
(
session
->
proxy_server
=
strdupW
(
info
.
lpszProxy
)))
if
(
info
.
lpszProxy
&&
!
(
session
->
proxy_server
=
wcsdup
(
info
.
lpszProxy
)))
{
GlobalFree
(
info
.
lpszProxy
);
GlobalFree
(
info
.
lpszProxyBypass
);
goto
end
;
}
if
(
info
.
lpszProxyBypass
&&
!
(
session
->
proxy_bypass
=
strdupW
(
info
.
lpszProxyBypass
)))
if
(
info
.
lpszProxyBypass
&&
!
(
session
->
proxy_bypass
=
wcsdup
(
info
.
lpszProxyBypass
)))
{
GlobalFree
(
info
.
lpszProxy
);
GlobalFree
(
info
.
lpszProxyBypass
);
...
...
@@ -345,8 +345,8 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
else
if
(
access
==
WINHTTP_ACCESS_TYPE_NAMED_PROXY
)
{
session
->
access
=
access
;
if
(
proxy
&&
!
(
session
->
proxy_server
=
strdupW
(
proxy
)))
goto
end
;
if
(
bypass
&&
!
(
session
->
proxy_bypass
=
strdupW
(
bypass
)))
goto
end
;
if
(
proxy
&&
!
(
session
->
proxy_server
=
wcsdup
(
proxy
)))
goto
end
;
if
(
bypass
&&
!
(
session
->
proxy_bypass
=
wcsdup
(
bypass
)))
goto
end
;
}
handle
=
alloc_handle
(
&
session
->
hdr
);
...
...
@@ -556,7 +556,7 @@ BOOL set_server_for_hostname( struct connect *connect, const WCHAR *server, INTE
{
free
(
connect
->
servername
);
connect
->
resolved
=
FALSE
;
if
(
!
(
connect
->
servername
=
strdupW
(
session
->
proxy_server
)))
if
(
!
(
connect
->
servername
=
wcsdup
(
session
->
proxy_server
)))
{
ret
=
FALSE
;
goto
end
;
...
...
@@ -569,7 +569,7 @@ BOOL set_server_for_hostname( struct connect *connect, const WCHAR *server, INTE
{
free
(
connect
->
servername
);
connect
->
resolved
=
FALSE
;
if
(
!
(
connect
->
servername
=
strdupW
(
server
)))
if
(
!
(
connect
->
servername
=
wcsdup
(
server
)))
{
ret
=
FALSE
;
goto
end
;
...
...
@@ -624,7 +624,7 @@ HINTERNET WINAPI WinHttpConnect( HINTERNET hsession, const WCHAR *server, INTERN
addref_object
(
&
session
->
hdr
);
connect
->
session
=
session
;
if
(
!
(
connect
->
hostname
=
strdupW
(
server
)))
goto
end
;
if
(
!
(
connect
->
hostname
=
wcsdup
(
server
)))
goto
end
;
connect
->
hostport
=
port
;
if
(
!
set_server_for_hostname
(
connect
,
server
,
port
))
goto
end
;
...
...
@@ -1273,11 +1273,11 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, const WCHAR *verb, cons
request
->
websocket_set_send_buffer_size
=
request
->
websocket_send_buffer_size
;
if
(
!
verb
||
!
verb
[
0
])
verb
=
L"GET"
;
if
(
!
(
request
->
verb
=
strdupW
(
verb
)))
goto
end
;
if
(
!
(
request
->
verb
=
wcsdup
(
verb
)))
goto
end
;
if
(
!
(
request
->
path
=
get_request_path
(
object
)))
goto
end
;
if
(
!
version
||
!
version
[
0
])
version
=
L"HTTP/1.1"
;
if
(
!
(
request
->
version
=
strdupW
(
version
)))
goto
end
;
if
(
!
(
request
->
version
=
wcsdup
(
version
)))
goto
end
;
if
(
!
(
add_accept_types_header
(
request
,
types
)))
goto
end
;
if
((
hrequest
=
alloc_handle
(
&
request
->
hdr
)))
...
...
dlls/winhttp/winhttp_private.h
View file @
ebe6e747
...
...
@@ -398,16 +398,6 @@ DWORD process_header( struct request *, const WCHAR *, const WCHAR *, DWORD, BOO
extern
HRESULT
WinHttpRequest_create
(
void
**
)
DECLSPEC_HIDDEN
;
void
release_typelib
(
void
)
DECLSPEC_HIDDEN
;
static
inline
WCHAR
*
strdupW
(
const
WCHAR
*
src
)
{
WCHAR
*
dst
;
if
(
!
src
)
return
NULL
;
dst
=
malloc
(
(
lstrlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
dst
)
lstrcpyW
(
dst
,
src
);
return
dst
;
}
static
inline
WCHAR
*
strdupAW
(
const
char
*
src
)
{
WCHAR
*
dst
=
NULL
;
...
...
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