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
4f961d9e
Commit
4f961d9e
authored
Jun 08, 2021
by
Hans Leidekker
Committed by
Alexandre Julliard
Jun 08, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
winhttp: Use CRT memory allocators.
Signed-off-by:
Hans Leidekker
<
hans@codeweavers.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
ed9c1fb1
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
286 additions
and
291 deletions
+286
-291
cookie.c
dlls/winhttp/cookie.c
+25
-25
handle.c
dlls/winhttp/handle.c
+5
-2
net.c
dlls/winhttp/net.c
+17
-17
request.c
dlls/winhttp/request.c
+159
-157
session.c
dlls/winhttp/session.c
+70
-74
url.c
dlls/winhttp/url.c
+4
-4
winhttp_private.h
dlls/winhttp/winhttp_private.h
+6
-12
No files found.
dlls/winhttp/cookie.c
View file @
4f961d9e
...
...
@@ -49,7 +49,7 @@ static struct domain *add_domain( struct session *session, WCHAR *name )
{
struct
domain
*
domain
;
if
(
!
(
domain
=
heap_alloc_zero
(
sizeof
(
struct
domain
)
)))
return
NULL
;
if
(
!
(
domain
=
calloc
(
1
,
sizeof
(
*
domain
)
)))
return
NULL
;
list_init
(
&
domain
->
entry
);
list_init
(
&
domain
->
cookies
);
...
...
@@ -89,10 +89,10 @@ static BOOL domain_match( const WCHAR *name, struct domain *domain, BOOL partial
static
void
free_cookie
(
struct
cookie
*
cookie
)
{
heap_
free
(
cookie
->
name
);
heap_
free
(
cookie
->
value
);
heap_
free
(
cookie
->
path
);
heap_
free
(
cookie
);
free
(
cookie
->
name
);
free
(
cookie
->
value
);
free
(
cookie
->
path
);
free
(
cookie
);
}
static
void
delete_cookie
(
struct
cookie
*
cookie
)
...
...
@@ -113,8 +113,8 @@ static void delete_domain( struct domain *domain )
}
list_remove
(
&
domain
->
entry
);
heap_
free
(
domain
->
name
);
heap_
free
(
domain
);
free
(
domain
->
name
);
free
(
domain
);
}
void
destroy_cookies
(
struct
session
*
session
)
...
...
@@ -170,12 +170,12 @@ static struct cookie *parse_cookie( const WCHAR *string )
while
(
len
&&
string
[
len
-
1
]
==
' '
)
len
--
;
if
(
!
len
)
return
NULL
;
if
(
!
(
cookie
=
heap_alloc_zero
(
sizeof
(
struct
cookie
)
)))
return
NULL
;
if
(
!
(
cookie
=
calloc
(
1
,
sizeof
(
*
cookie
)
)))
return
NULL
;
list_init
(
&
cookie
->
entry
);
if
(
!
(
cookie
->
name
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
cookie
->
name
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
heap_
free
(
cookie
);
free
(
cookie
);
return
NULL
;
}
memcpy
(
cookie
->
name
,
string
,
len
*
sizeof
(
WCHAR
)
);
...
...
@@ -187,7 +187,7 @@ static struct cookie *parse_cookie( const WCHAR *string )
len
=
lstrlenW
(
p
);
while
(
len
&&
p
[
len
-
1
]
==
' '
)
len
--
;
if
(
!
(
cookie
->
value
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
cookie
->
value
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
free_cookie
(
cookie
);
return
NULL
;
...
...
@@ -207,9 +207,9 @@ struct attr
static
void
free_attr
(
struct
attr
*
attr
)
{
if
(
!
attr
)
return
;
heap_
free
(
attr
->
name
);
heap_
free
(
attr
->
value
);
heap_
free
(
attr
);
free
(
attr
->
name
);
free
(
attr
->
value
);
free
(
attr
);
}
static
struct
attr
*
parse_attr
(
const
WCHAR
*
str
,
int
*
used
)
...
...
@@ -224,10 +224,10 @@ static struct attr *parse_attr( const WCHAR *str, int *used )
len
=
q
-
p
;
if
(
!
len
)
return
NULL
;
if
(
!
(
attr
=
heap_alloc
(
sizeof
(
struct
attr
)
)))
return
NULL
;
if
(
!
(
attr
->
name
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
attr
=
malloc
(
sizeof
(
*
attr
)
)))
return
NULL
;
if
(
!
(
attr
->
name
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
heap_
free
(
attr
);
free
(
attr
);
return
NULL
;
}
memcpy
(
attr
->
name
,
p
,
len
*
sizeof
(
WCHAR
)
);
...
...
@@ -244,7 +244,7 @@ static struct attr *parse_attr( const WCHAR *str, int *used )
len
=
q
-
p
;
while
(
len
&&
p
[
len
-
1
]
==
' '
)
len
--
;
if
(
!
(
attr
->
value
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
attr
->
value
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
free_attr
(
attr
);
return
NULL
;
...
...
@@ -271,7 +271,7 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
int
len
,
used
;
len
=
lstrlenW
(
cookies
);
if
(
!
(
buffer
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
if
(
!
(
buffer
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
lstrcpyW
(
buffer
,
cookies
);
p
=
buffer
;
...
...
@@ -279,7 +279,7 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
if
(
*
p
==
';'
)
*
p
++
=
0
;
if
(
!
(
cookie
=
parse_cookie
(
buffer
)))
{
heap_
free
(
buffer
);
free
(
buffer
);
return
FALSE
;
}
len
=
lstrlenW
(
p
);
...
...
@@ -312,10 +312,10 @@ BOOL set_cookies( struct request *request, const WCHAR *cookies )
end:
if
(
!
ret
)
free_cookie
(
cookie
);
if
(
domain
)
free_attr
(
domain
);
else
heap_
free
(
cookie_domain
);
else
free
(
cookie_domain
);
if
(
path
)
free_attr
(
path
);
else
heap_
free
(
cookie_path
);
heap_
free
(
buffer
);
else
free
(
cookie_path
);
free
(
buffer
);
return
ret
;
}
...
...
@@ -349,7 +349,7 @@ DWORD add_cookie_headers( struct request *request )
len
=
len_cookie
+
len_name
;
if
(
cookie
->
value
)
len
+=
lstrlenW
(
cookie
->
value
)
+
1
;
if
(
!
(
header
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
header
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
LeaveCriticalSection
(
&
session
->
cs
);
return
ERROR_OUTOFMEMORY
;
...
...
@@ -366,7 +366,7 @@ DWORD add_cookie_headers( struct request *request )
TRACE
(
"%s
\n
"
,
debugstr_w
(
header
));
ret
=
add_request_headers
(
request
,
header
,
len
,
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_SEMICOLON
);
heap_
free
(
header
);
free
(
header
);
}
}
}
...
...
dlls/winhttp/handle.c
View file @
4f961d9e
...
...
@@ -94,14 +94,17 @@ HINTERNET alloc_handle( struct object_header *hdr )
if
(
!
max_handles
)
{
num
=
HANDLE_CHUNK_SIZE
;
if
(
!
(
p
=
heap_alloc_zero
(
sizeof
(
ULONG_PTR
)
*
num
)))
goto
end
;
if
(
!
(
p
=
calloc
(
1
,
sizeof
(
ULONG_PTR
)
*
num
)))
goto
end
;
handles
=
p
;
max_handles
=
num
;
}
if
(
max_handles
==
next_handle
)
{
size_t
new_size
,
old_size
=
max_handles
*
sizeof
(
ULONG_PTR
);
num
=
max_handles
*
2
;
if
(
!
(
p
=
heap_realloc_zero
(
handles
,
sizeof
(
ULONG_PTR
)
*
num
)))
goto
end
;
new_size
=
num
*
sizeof
(
ULONG_PTR
);
if
(
!
(
p
=
realloc
(
handles
,
new_size
)))
goto
end
;
memset
(
(
char
*
)
p
+
old_size
,
0
,
new_size
-
old_size
);
handles
=
p
;
max_handles
=
num
;
}
...
...
dlls/winhttp/net.c
View file @
4f961d9e
...
...
@@ -187,14 +187,14 @@ DWORD netconn_create( struct hostdata *host, const struct sockaddr_storage *sock
winsock_init
();
if
(
!
(
conn
=
heap_alloc_zero
(
sizeof
(
*
conn
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
conn
=
calloc
(
1
,
sizeof
(
*
conn
)
)))
return
ERROR_OUTOFMEMORY
;
conn
->
host
=
host
;
conn
->
sockaddr
=
*
sockaddr
;
if
((
conn
->
socket
=
socket
(
sockaddr
->
ss_family
,
SOCK_STREAM
,
0
))
==
-
1
)
{
ret
=
WSAGetLastError
();
WARN
(
"unable to create socket (%u)
\n
"
,
ret
);
heap_
free
(
conn
);
free
(
conn
);
return
ret
;
}
...
...
@@ -208,7 +208,7 @@ DWORD netconn_create( struct hostdata *host, const struct sockaddr_storage *sock
break
;
default:
ERR
(
"unhandled family %u
\n
"
,
conn
->
sockaddr
.
ss_family
);
heap_
free
(
conn
);
free
(
conn
);
return
ERROR_INVALID_PARAMETER
;
}
...
...
@@ -237,7 +237,7 @@ DWORD netconn_create( struct hostdata *host, const struct sockaddr_storage *sock
{
WARN
(
"unable to connect to host (%u)
\n
"
,
ret
);
closesocket
(
conn
->
socket
);
heap_
free
(
conn
);
free
(
conn
);
return
ret
;
}
...
...
@@ -249,14 +249,14 @@ void netconn_close( struct netconn *conn )
{
if
(
conn
->
secure
)
{
heap_
free
(
conn
->
peek_msg_mem
);
heap_
free
(
conn
->
ssl_buf
);
heap_
free
(
conn
->
extra_buf
);
free
(
conn
->
peek_msg_mem
);
free
(
conn
->
ssl_buf
);
free
(
conn
->
extra_buf
);
DeleteSecurityContext
(
&
conn
->
ssl_ctx
);
}
closesocket
(
conn
->
socket
);
release_host
(
conn
->
host
);
heap_
free
(
conn
);
free
(
conn
);
}
DWORD
netconn_secure_connect
(
struct
netconn
*
conn
,
WCHAR
*
hostname
,
DWORD
security_flags
,
CredHandle
*
cred_handle
,
...
...
@@ -276,7 +276,7 @@ DWORD netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD secur
const
DWORD
isc_req_flags
=
ISC_REQ_ALLOCATE_MEMORY
|
ISC_REQ_USE_SESSION_KEY
|
ISC_REQ_CONFIDENTIALITY
|
ISC_REQ_SEQUENCE_DETECT
|
ISC_REQ_REPLAY_DETECT
|
ISC_REQ_MANUAL_CRED_VALIDATION
;
if
(
!
(
read_buf
=
heap_
alloc
(
read_buf_size
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
read_buf
=
m
alloc
(
read_buf_size
)))
return
ERROR_OUTOFMEMORY
;
status
=
InitializeSecurityContextW
(
cred_handle
,
NULL
,
hostname
,
isc_req_flags
,
0
,
0
,
NULL
,
0
,
&
ctx
,
&
out_desc
,
&
attrs
,
NULL
);
...
...
@@ -318,7 +318,7 @@ DWORD netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD secur
if
(
in_bufs
[
0
].
cbBuffer
+
1024
>
read_buf_size
)
{
BYTE
*
new_read_buf
;
new_read_buf
=
heap_
realloc
(
read_buf
,
read_buf_size
+
1024
);
new_read_buf
=
realloc
(
read_buf
,
read_buf_size
+
1024
);
if
(
!
new_read_buf
)
{
status
=
E_OUTOFMEMORY
;
break
;
...
...
@@ -365,7 +365,7 @@ DWORD netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD secur
break
;
}
conn
->
ssl_buf
=
heap_
alloc
(
conn
->
ssl_sizes
.
cbHeader
+
conn
->
ssl_sizes
.
cbMaximumMessage
+
conn
->
ssl_sizes
.
cbTrailer
);
conn
->
ssl_buf
=
m
alloc
(
conn
->
ssl_sizes
.
cbHeader
+
conn
->
ssl_sizes
.
cbMaximumMessage
+
conn
->
ssl_sizes
.
cbTrailer
);
if
(
!
conn
->
ssl_buf
)
{
res
=
ERROR_OUTOFMEMORY
;
break
;
...
...
@@ -373,11 +373,11 @@ DWORD netconn_secure_connect( struct netconn *conn, WCHAR *hostname, DWORD secur
}
}
heap_
free
(
read_buf
);
free
(
read_buf
);
if
(
status
!=
SEC_E_OK
||
res
!=
ERROR_SUCCESS
)
{
WARN
(
"Failed to initialize security context: %08x
\n
"
,
status
);
heap_
free
(
conn
->
ssl_buf
);
free
(
conn
->
ssl_buf
);
conn
->
ssl_buf
=
NULL
;
DeleteSecurityContext
(
&
ctx
);
return
ERROR_WINHTTP_SECURE_CHANNEL_ERROR
;
...
...
@@ -459,7 +459,7 @@ static DWORD read_ssl_chunk( struct netconn *conn, void *buf, SIZE_T buf_size, S
memcpy
(
conn
->
ssl_buf
,
conn
->
extra_buf
,
conn
->
extra_len
);
buf_len
=
conn
->
extra_len
;
conn
->
extra_len
=
0
;
heap_
free
(
conn
->
extra_buf
);
free
(
conn
->
extra_buf
);
conn
->
extra_buf
=
NULL
;
}
else
{
if
((
buf_len
=
sock_recv
(
conn
->
socket
,
conn
->
ssl_buf
+
conn
->
extra_len
,
ssl_buf_size
-
conn
->
extra_len
,
0
))
<
0
)
...
...
@@ -516,7 +516,7 @@ static DWORD read_ssl_chunk( struct netconn *conn, void *buf, SIZE_T buf_size, S
memcpy
(
buf
,
bufs
[
i
].
pvBuffer
,
size
);
if
(
size
<
bufs
[
i
].
cbBuffer
)
{
assert
(
!
conn
->
peek_len
);
conn
->
peek_msg_mem
=
conn
->
peek_msg
=
heap_
alloc
(
bufs
[
i
].
cbBuffer
-
size
);
conn
->
peek_msg_mem
=
conn
->
peek_msg
=
m
alloc
(
bufs
[
i
].
cbBuffer
-
size
);
if
(
!
conn
->
peek_msg
)
return
ERROR_OUTOFMEMORY
;
conn
->
peek_len
=
bufs
[
i
].
cbBuffer
-
size
;
...
...
@@ -529,7 +529,7 @@ static DWORD read_ssl_chunk( struct netconn *conn, void *buf, SIZE_T buf_size, S
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
bufs
);
i
++
)
{
if
(
bufs
[
i
].
BufferType
==
SECBUFFER_EXTRA
)
{
conn
->
extra_buf
=
heap_
alloc
(
bufs
[
i
].
cbBuffer
);
conn
->
extra_buf
=
m
alloc
(
bufs
[
i
].
cbBuffer
);
if
(
!
conn
->
extra_buf
)
return
ERROR_OUTOFMEMORY
;
...
...
@@ -561,7 +561,7 @@ DWORD netconn_recv( struct netconn *conn, void *buf, size_t len, int flags, int
if
(
conn
->
peek_len
==
0
)
{
heap_
free
(
conn
->
peek_msg_mem
);
free
(
conn
->
peek_msg_mem
);
conn
->
peek_msg_mem
=
NULL
;
conn
->
peek_msg
=
NULL
;
}
...
...
dlls/winhttp/request.c
View file @
4f961d9e
...
...
@@ -163,9 +163,9 @@ static DWORD queue_task( struct queue *queue, PTP_WORK_CALLBACK task, void *ctx
static
void
free_header
(
struct
header
*
header
)
{
heap_
free
(
header
->
field
);
heap_
free
(
header
->
value
);
heap_
free
(
header
);
free
(
header
->
field
);
free
(
header
->
value
);
free
(
header
);
}
static
BOOL
valid_token_char
(
WCHAR
c
)
...
...
@@ -216,10 +216,10 @@ static struct header *parse_header( const WCHAR *string )
p
++
;
}
len
=
q
-
string
;
if
(
!
(
header
=
heap_alloc_zero
(
sizeof
(
struct
header
)
)))
return
NULL
;
if
(
!
(
header
->
field
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
header
=
calloc
(
1
,
sizeof
(
*
header
)
)))
return
NULL
;
if
(
!
(
header
->
field
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
heap_
free
(
header
);
free
(
header
);
return
NULL
;
}
memcpy
(
header
->
field
,
string
,
len
*
sizeof
(
WCHAR
)
);
...
...
@@ -229,7 +229,7 @@ static struct header *parse_header( const WCHAR *string )
while
(
*
q
==
' '
)
q
++
;
len
=
lstrlenW
(
q
);
if
(
!
(
header
->
value
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
header
->
value
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
free_header
(
header
);
return
NULL
;
...
...
@@ -266,9 +266,11 @@ static DWORD insert_header( struct request *request, struct header *header )
struct
header
*
hdrs
;
if
(
request
->
headers
)
hdrs
=
heap_realloc_zero
(
request
->
headers
,
sizeof
(
struct
header
)
*
count
);
else
hdrs
=
heap_alloc_zero
(
sizeof
(
struct
header
)
);
{
if
((
hdrs
=
realloc
(
request
->
headers
,
sizeof
(
*
header
)
*
count
)))
memset
(
&
hdrs
[
count
-
1
],
0
,
sizeof
(
*
header
)
);
}
else
hdrs
=
calloc
(
1
,
sizeof
(
*
header
)
);
if
(
!
hdrs
)
return
ERROR_OUTOFMEMORY
;
request
->
headers
=
hdrs
;
...
...
@@ -284,8 +286,8 @@ static void delete_header( struct request *request, DWORD index )
if
(
!
request
->
num_headers
||
index
>=
request
->
num_headers
)
return
;
request
->
num_headers
--
;
heap_
free
(
request
->
headers
[
index
].
field
);
heap_
free
(
request
->
headers
[
index
].
value
);
free
(
request
->
headers
[
index
].
field
);
free
(
request
->
headers
[
index
].
value
);
memmove
(
&
request
->
headers
[
index
],
&
request
->
headers
[
index
+
1
],
(
request
->
num_headers
-
index
)
*
sizeof
(
struct
header
)
);
...
...
@@ -332,7 +334,7 @@ DWORD process_header( struct request *request, const WCHAR *field, const WCHAR *
len_value
=
lstrlenW
(
value
);
len
=
len_orig
+
len_value
+
2
;
if
(
!
(
tmp
=
heap_
realloc
(
header
->
value
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
tmp
=
realloc
(
header
->
value
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
header
->
value
=
tmp
;
header
->
value
[
len_orig
++
]
=
(
flags
&
WINHTTP_ADDREQ_FLAG_COALESCE_WITH_COMMA
)
?
','
:
';'
;
header
->
value
[
len_orig
++
]
=
' '
;
...
...
@@ -361,7 +363,7 @@ DWORD add_request_headers( struct request *request, const WCHAR *headers, DWORD
if
(
len
==
~
0u
)
len
=
lstrlenW
(
headers
);
if
(
!
len
)
return
ERROR_SUCCESS
;
if
(
!
(
buffer
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
buffer
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
memcpy
(
buffer
,
headers
,
len
*
sizeof
(
WCHAR
)
);
buffer
[
len
]
=
0
;
...
...
@@ -393,7 +395,7 @@ DWORD add_request_headers( struct request *request, const WCHAR *headers, DWORD
p
=
q
;
}
while
(
!
ret
);
heap_
free
(
buffer
);
free
(
buffer
);
return
ret
;
}
...
...
@@ -443,7 +445,7 @@ static WCHAR *build_absolute_request_path( struct request *request, const WCHAR
if
(
request
->
connect
->
hostport
)
len
+=
6
;
/* ':' between host and port, up to 5 for port */
len
+=
lstrlenW
(
request
->
path
);
if
((
ret
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
if
((
ret
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
{
offset
=
swprintf
(
ret
,
len
,
L"%s://%s"
,
scheme
,
request
->
connect
->
hostname
);
if
(
request
->
connect
->
hostport
)
...
...
@@ -476,7 +478,7 @@ static WCHAR *build_request_string( struct request *request )
}
len
+=
4
;
/* '\r\n\r\n' */
if
((
ret
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
((
ret
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
lstrcpyW
(
ret
,
request
->
verb
);
lstrcatW
(
ret
,
L" "
);
...
...
@@ -497,7 +499,7 @@ static WCHAR *build_request_string( struct request *request )
lstrcatW
(
ret
,
L"
\r\n\r\n
"
);
}
if
(
path
!=
request
->
path
)
heap_
free
(
path
);
if
(
path
!=
request
->
path
)
free
(
path
);
return
ret
;
}
...
...
@@ -551,7 +553,7 @@ static DWORD query_headers( struct request *request, DWORD level, const WCHAR *n
ret
=
ERROR_SUCCESS
;
}
*
buflen
=
len
*
sizeof
(
WCHAR
);
if
(
request_only
)
heap_
free
(
headers
);
if
(
request_only
)
free
(
headers
);
return
ret
;
}
case
WINHTTP_QUERY_RAW_HEADERS_CRLF
:
...
...
@@ -577,7 +579,7 @@ static DWORD query_headers( struct request *request, DWORD level, const WCHAR *n
ret
=
ERROR_SUCCESS
;
}
*
buflen
=
len
;
if
(
request_only
)
heap_
free
(
headers
);
if
(
request_only
)
free
(
headers
);
return
ret
;
}
case
WINHTTP_QUERY_VERSION
:
...
...
@@ -771,14 +773,14 @@ static DWORD query_auth_schemes( struct request *request, DWORD level, DWORD *su
break
;
}
if
(
!
(
buffer
=
heap_
alloc
(
size
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
buffer
=
m
alloc
(
size
)))
return
ERROR_OUTOFMEMORY
;
if
((
ret
=
query_headers
(
request
,
level
,
NULL
,
buffer
,
&
size
,
&
index
)))
{
heap_
free
(
buffer
);
free
(
buffer
);
return
ret
;
}
scheme
=
auth_scheme_from_header
(
buffer
);
heap_
free
(
buffer
);
free
(
buffer
);
if
(
!
scheme
)
continue
;
if
(
!
first_scheme
)
first_scheme
=
scheme
;
...
...
@@ -954,7 +956,7 @@ static struct authinfo *alloc_authinfo(void)
{
struct
authinfo
*
ret
;
if
(
!
(
ret
=
heap_
alloc
(
sizeof
(
*
ret
)
)))
return
NULL
;
if
(
!
(
ret
=
m
alloc
(
sizeof
(
*
ret
)
)))
return
NULL
;
SecInvalidateHandle
(
&
ret
->
cred
);
SecInvalidateHandle
(
&
ret
->
ctx
);
...
...
@@ -977,8 +979,8 @@ void destroy_authinfo( struct authinfo *authinfo )
if
(
SecIsValidHandle
(
&
authinfo
->
cred
))
FreeCredentialsHandle
(
&
authinfo
->
cred
);
heap_
free
(
authinfo
->
data
);
heap_
free
(
authinfo
);
free
(
authinfo
->
data
);
free
(
authinfo
);
}
static
BOOL
get_authvalue
(
struct
request
*
request
,
DWORD
level
,
DWORD
scheme
,
WCHAR
*
buffer
,
DWORD
len
)
...
...
@@ -1060,7 +1062,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
passlen
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
password
,
lstrlenW
(
password
),
NULL
,
0
,
NULL
,
NULL
);
authinfo
->
data_len
=
userlen
+
1
+
passlen
;
if
(
!
(
authinfo
->
data
=
heap_
alloc
(
authinfo
->
data_len
)))
return
FALSE
;
if
(
!
(
authinfo
->
data
=
m
alloc
(
authinfo
->
data_len
)))
return
FALSE
;
WideCharToMultiByte
(
CP_UTF8
,
0
,
username
,
-
1
,
authinfo
->
data
,
userlen
,
NULL
,
NULL
);
authinfo
->
data
[
userlen
]
=
':'
;
...
...
@@ -1123,7 +1125,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
{
WARN
(
"AcquireCredentialsHandleW for scheme %s failed with error 0x%08x
\n
"
,
debugstr_w
(
auth_schemes
[
scheme
].
str
),
status
);
heap_
free
(
authinfo
);
free
(
authinfo
);
return
FALSE
;
}
authinfo
->
scheme
=
scheme
;
...
...
@@ -1152,7 +1154,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
{
int
len
=
lstrlenW
(
++
p
);
in
.
cbBuffer
=
decode_base64
(
p
,
len
,
NULL
);
if
(
!
(
in
.
pvBuffer
=
heap_
alloc
(
in
.
cbBuffer
)))
{
if
(
!
(
in
.
pvBuffer
=
m
alloc
(
in
.
cbBuffer
)))
{
destroy_authinfo
(
authinfo
);
*
auth_ptr
=
NULL
;
return
FALSE
;
...
...
@@ -1161,9 +1163,9 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
}
out
.
BufferType
=
SECBUFFER_TOKEN
;
out
.
cbBuffer
=
authinfo
->
max_token
;
if
(
!
(
out
.
pvBuffer
=
heap_
alloc
(
authinfo
->
max_token
)))
if
(
!
(
out
.
pvBuffer
=
m
alloc
(
authinfo
->
max_token
)))
{
heap_
free
(
in
.
pvBuffer
);
free
(
in
.
pvBuffer
);
destroy_authinfo
(
authinfo
);
*
auth_ptr
=
NULL
;
return
FALSE
;
...
...
@@ -1176,10 +1178,10 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
first
?
request
->
connect
->
servername
:
NULL
,
flags
,
0
,
SECURITY_NETWORK_DREP
,
in
.
pvBuffer
?
&
in_desc
:
NULL
,
0
,
&
authinfo
->
ctx
,
&
out_desc
,
&
authinfo
->
attr
,
&
authinfo
->
exp
);
heap_
free
(
in
.
pvBuffer
);
free
(
in
.
pvBuffer
);
if
(
status
==
SEC_E_OK
)
{
heap_
free
(
authinfo
->
data
);
free
(
authinfo
->
data
);
authinfo
->
data
=
out
.
pvBuffer
;
authinfo
->
data_len
=
out
.
cbBuffer
;
authinfo
->
finished
=
TRUE
;
...
...
@@ -1187,7 +1189,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
}
else
if
(
status
==
SEC_I_CONTINUE_NEEDED
)
{
heap_
free
(
authinfo
->
data
);
free
(
authinfo
->
data
);
authinfo
->
data
=
out
.
pvBuffer
;
authinfo
->
data_len
=
out
.
cbBuffer
;
TRACE
(
"sending next auth packet
\n
"
);
...
...
@@ -1195,7 +1197,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
else
{
ERR
(
"InitializeSecurityContextW failed with error 0x%08x
\n
"
,
status
);
heap_
free
(
out
.
pvBuffer
);
free
(
out
.
pvBuffer
);
destroy_authinfo
(
authinfo
);
*
auth_ptr
=
NULL
;
return
FALSE
;
...
...
@@ -1210,7 +1212,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
len_scheme
=
auth_schemes
[
authinfo
->
scheme
].
len
;
len
=
len_scheme
+
1
+
((
authinfo
->
data_len
+
2
)
*
4
)
/
3
;
if
(
!
(
auth_reply
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
if
(
!
(
auth_reply
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
FALSE
;
memcpy
(
auth_reply
,
auth_schemes
[
authinfo
->
scheme
].
str
,
len_scheme
*
sizeof
(
WCHAR
)
);
auth_reply
[
len_scheme
]
=
' '
;
...
...
@@ -1218,7 +1220,7 @@ static BOOL do_authorization( struct request *request, DWORD target, DWORD schem
flags
=
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
;
ret
=
!
process_header
(
request
,
auth_target
,
auth_reply
,
flags
,
TRUE
);
heap_
free
(
auth_reply
);
free
(
auth_reply
);
return
ret
;
}
...
...
@@ -1228,7 +1230,7 @@ static WCHAR *build_proxy_connect_string( struct request *request )
unsigned
int
i
;
int
len
=
lstrlenW
(
request
->
connect
->
hostname
)
+
7
;
if
(
!
(
host
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
!
(
host
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
NULL
;
len
=
swprintf
(
host
,
len
,
L"%s:%u"
,
request
->
connect
->
hostname
,
request
->
connect
->
hostport
);
len
+=
ARRAY_SIZE
(
L"CONNECT"
);
...
...
@@ -1241,7 +1243,7 @@ static WCHAR *build_proxy_connect_string( struct request *request )
}
len
+=
4
;
/* '\r\n\r\n' */
if
((
ret
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
((
ret
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
lstrcpyW
(
ret
,
L"CONNECT"
);
lstrcatW
(
ret
,
L" "
);
...
...
@@ -1262,7 +1264,7 @@ static WCHAR *build_proxy_connect_string( struct request *request )
lstrcatW
(
ret
,
L"
\r\n\r\n
"
);
}
heap_
free
(
host
);
free
(
host
);
return
ret
;
}
...
...
@@ -1277,12 +1279,12 @@ static DWORD secure_proxy_connect( struct request *request )
if
(
!
(
str
=
build_proxy_connect_string
(
request
)))
return
ERROR_OUTOFMEMORY
;
strA
=
strdupWA
(
str
);
heap_
free
(
str
);
free
(
str
);
if
(
!
strA
)
return
ERROR_OUTOFMEMORY
;
len
=
strlen
(
strA
);
ret
=
netconn_send
(
request
->
netconn
,
strA
,
len
,
&
bytes_sent
);
heap_
free
(
strA
);
free
(
strA
);
if
(
!
ret
)
ret
=
read_reply
(
request
);
return
ret
;
...
...
@@ -1330,8 +1332,8 @@ void release_host( struct hostdata *host )
if
(
ref
)
return
;
assert
(
list_empty
(
&
host
->
connections
)
);
heap_
free
(
host
->
hostname
);
heap_
free
(
host
);
free
(
host
->
hostname
);
free
(
host
);
}
static
BOOL
connection_collector_running
;
...
...
@@ -1467,7 +1469,7 @@ static DWORD open_connection( struct request *request )
if
(
!
host
)
{
if
((
host
=
heap_
alloc
(
sizeof
(
*
host
)
)))
if
((
host
=
m
alloc
(
sizeof
(
*
host
)
)))
{
host
->
ref
=
1
;
host
->
secure
=
is_secure
;
...
...
@@ -1479,7 +1481,7 @@ static DWORD open_connection( struct request *request )
}
else
{
heap_
free
(
host
);
free
(
host
);
host
=
NULL
;
}
}
...
...
@@ -1548,7 +1550,7 @@ static DWORD open_connection( struct request *request )
if
((
ret
=
netconn_create
(
host
,
&
connect
->
sockaddr
,
request
->
connect_timeout
,
&
netconn
)))
{
heap_
free
(
addressW
);
free
(
addressW
);
release_host
(
host
);
return
ret
;
}
...
...
@@ -1564,7 +1566,7 @@ static DWORD open_connection( struct request *request )
if
((
ret
=
secure_proxy_connect
(
request
)))
{
request
->
netconn
=
NULL
;
heap_
free
(
addressW
);
free
(
addressW
);
netconn_close
(
netconn
);
return
ret
;
}
...
...
@@ -1578,7 +1580,7 @@ static DWORD open_connection( struct request *request )
&
request
->
cred_handle
,
request
->
check_revocation
)))
{
request
->
netconn
=
NULL
;
heap_
free
(
addressW
);
free
(
addressW
);
netconn_close
(
netconn
);
return
ret
;
}
...
...
@@ -1597,7 +1599,7 @@ static DWORD open_connection( struct request *request )
if
(
netconn
->
secure
&&
!
(
request
->
server_cert
=
netconn_get_certificate
(
netconn
)))
{
heap_
free
(
addressW
);
free
(
addressW
);
netconn_close
(
netconn
);
return
ERROR_WINHTTP_SECURE_FAILURE
;
}
...
...
@@ -1607,7 +1609,7 @@ done:
request
->
read_chunked
=
FALSE
;
request
->
read_chunked_size
=
~
0u
;
request
->
read_chunked_eof
=
FALSE
;
heap_
free
(
addressW
);
free
(
addressW
);
return
ERROR_SUCCESS
;
}
...
...
@@ -1635,10 +1637,10 @@ static DWORD add_host_header( struct request *request, DWORD modifier )
return
process_header
(
request
,
L"Host"
,
connect
->
hostname
,
modifier
,
TRUE
);
}
len
=
lstrlenW
(
connect
->
hostname
)
+
7
;
/* sizeof(":65335") */
if
(
!
(
host
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
host
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
swprintf
(
host
,
len
,
L"%s:%u"
,
connect
->
hostname
,
port
);
ret
=
process_header
(
request
,
L"Host"
,
host
,
modifier
,
TRUE
);
heap_
free
(
host
);
free
(
host
);
return
ret
;
}
...
...
@@ -1950,11 +1952,11 @@ static DWORD str_to_wire( const WCHAR *src, int src_len, char *dst, enum escape_
if
(
src_len
<
0
)
src_len
=
lstrlenW
(
src
);
len
=
WideCharToMultiByte
(
CP_UTF8
,
0
,
src
,
src_len
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
(
utf8
=
heap_
alloc
(
len
)))
return
0
;
if
(
!
(
utf8
=
m
alloc
(
len
)))
return
0
;
WideCharToMultiByte
(
CP_UTF8
,
0
,
src
,
-
1
,
utf8
,
len
,
NULL
,
NULL
);
len
=
escape_string
(
utf8
,
len
,
dst
,
flags
);
heap_
free
(
utf8
);
free
(
utf8
);
return
len
;
}
...
...
@@ -1992,14 +1994,14 @@ static char *build_wire_path( struct request *request, DWORD *ret_len )
if
(
path
)
*
ret_len
+=
str_to_wire
(
path
,
len_path
,
NULL
,
path_flags
);
if
(
query
)
*
ret_len
+=
str_to_wire
(
query
,
len_query
,
NULL
,
query_flags
);
if
((
ret
=
heap_
alloc
(
*
ret_len
+
1
)))
if
((
ret
=
m
alloc
(
*
ret_len
+
1
)))
{
len
=
str_to_wire
(
full_path
,
len
-
len_path
-
len_query
,
ret
,
0
);
if
(
path
)
len
+=
str_to_wire
(
path
,
len_path
,
ret
+
len
,
path_flags
);
if
(
query
)
str_to_wire
(
query
,
len_query
,
ret
+
len
,
query_flags
);
}
if
(
full_path
!=
request
->
path
)
heap_
free
(
full_path
);
if
(
full_path
!=
request
->
path
)
free
(
full_path
);
return
ret
;
}
...
...
@@ -2024,7 +2026,7 @@ static char *build_wire_request( struct request *request, DWORD *len )
}
*
len
+=
4
;
/* '\r\n\r\n' */
if
((
ret
=
ptr
=
heap_
alloc
(
*
len
+
1
)))
if
((
ret
=
ptr
=
m
alloc
(
*
len
+
1
)))
{
ptr
+=
str_to_wire
(
request
->
verb
,
-
1
,
ptr
,
0
);
*
ptr
++
=
' '
;
...
...
@@ -2048,7 +2050,7 @@ static char *build_wire_request( struct request *request, DWORD *len )
memcpy
(
ptr
,
"
\r\n\r\n
"
,
sizeof
(
"
\r\n\r\n
"
)
);
}
heap_
free
(
path
);
free
(
path
);
return
ret
;
}
...
...
@@ -2058,7 +2060,7 @@ static WCHAR *create_websocket_key(void)
char
buf
[
16
];
DWORD
base64_len
=
((
sizeof
(
buf
)
+
2
)
*
4
)
/
3
;
if
(
!
RtlGenRandom
(
buf
,
sizeof
(
buf
)
))
return
NULL
;
if
((
ret
=
heap_
alloc
(
(
base64_len
+
1
)
*
sizeof
(
WCHAR
)
)))
encode_base64
(
buf
,
sizeof
(
buf
),
ret
);
if
((
ret
=
m
alloc
(
(
base64_len
+
1
)
*
sizeof
(
WCHAR
)
)))
encode_base64
(
buf
,
sizeof
(
buf
),
ret
);
return
ret
;
}
...
...
@@ -2067,7 +2069,7 @@ static DWORD add_websocket_key_header( struct request *request )
WCHAR
*
key
=
create_websocket_key
();
if
(
!
key
)
return
ERROR_OUTOFMEMORY
;
process_header
(
request
,
L"Sec-WebSocket-Key"
,
key
,
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
,
TRUE
);
heap_
free
(
key
);
free
(
key
);
return
ERROR_SUCCESS
;
}
...
...
@@ -2139,7 +2141,7 @@ static DWORD send_request( struct request *request, const WCHAR *headers, DWORD
send_callback
(
&
request
->
hdr
,
WINHTTP_CALLBACK_STATUS_SENDING_REQUEST
,
NULL
,
0
);
ret
=
netconn_send
(
request
->
netconn
,
wire_req
,
len
,
&
bytes_sent
);
heap_
free
(
wire_req
);
free
(
wire_req
);
if
(
ret
)
goto
end
;
if
(
optional_len
)
...
...
@@ -2174,8 +2176,8 @@ static void CALLBACK task_send_request( TP_CALLBACK_INSTANCE *instance, void *ct
send_request
(
s
->
request
,
s
->
headers
,
s
->
headers_len
,
s
->
optional
,
s
->
optional_len
,
s
->
total_len
,
s
->
context
,
TRUE
);
release_object
(
&
s
->
request
->
hdr
);
heap_
free
(
s
->
headers
);
heap_
free
(
s
);
free
(
s
->
headers
);
free
(
s
);
}
/***********************************************************************
...
...
@@ -2208,7 +2210,7 @@ BOOL WINAPI WinHttpSendRequest( HINTERNET hrequest, LPCWSTR headers, DWORD heade
{
struct
send_request
*
s
;
if
(
!
(
s
=
heap_
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
if
(
!
(
s
=
m
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
s
->
request
=
request
;
s
->
headers
=
strdupW
(
headers
);
s
->
headers_len
=
headers_len
;
...
...
@@ -2221,8 +2223,8 @@ BOOL WINAPI WinHttpSendRequest( HINTERNET hrequest, LPCWSTR headers, DWORD heade
if
((
ret
=
queue_task
(
&
request
->
queue
,
task_send_request
,
s
)))
{
release_object
(
&
request
->
hdr
);
heap_
free
(
s
->
headers
);
heap_
free
(
s
);
free
(
s
->
headers
);
free
(
s
);
}
}
else
ret
=
send_request
(
request
,
headers
,
headers_len
,
optional
,
optional_len
,
total_len
,
context
,
FALSE
);
...
...
@@ -2245,22 +2247,22 @@ static DWORD set_credentials( struct request *request, DWORD target, DWORD schem
{
case
WINHTTP_AUTH_TARGET_SERVER
:
{
heap_
free
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
username
);
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
;
heap_
free
(
request
->
creds
[
TARGET_SERVER
][
scheme
].
password
);
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
;
break
;
}
case
WINHTTP_AUTH_TARGET_PROXY
:
{
heap_
free
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
username
);
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
;
heap_
free
(
request
->
creds
[
TARGET_PROXY
][
scheme
].
password
);
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
;
break
;
...
...
@@ -2443,26 +2445,26 @@ static DWORD read_reply( struct request *request )
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
,
FALSE
)))
return
ret
;
len
=
status_code
-
buffer
;
if
(
!
(
versionW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
versionW
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
buffer
,
len
-
1
,
versionW
,
len
-
1
);
versionW
[
len
-
1
]
=
0
;
heap_
free
(
request
->
version
);
free
(
request
->
version
);
request
->
version
=
versionW
;
len
=
buflen
-
(
status_text
-
buffer
);
if
(
!
(
status_textW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
status_textW
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
status_text
,
len
,
status_textW
,
len
);
heap_
free
(
request
->
status_text
);
free
(
request
->
status_text
);
request
->
status_text
=
status_textW
;
len
=
max
(
buflen
+
crlf_len
,
INITIAL_HEADER_BUFFER_LEN
);
if
(
!
(
raw_headers
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
raw_headers
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
buffer
,
buflen
,
raw_headers
,
buflen
);
memcpy
(
raw_headers
+
buflen
-
1
,
L"
\r\n
"
,
sizeof
(
L"
\r\n
"
)
);
heap_
free
(
request
->
raw_headers
);
free
(
request
->
raw_headers
);
request
->
raw_headers
=
raw_headers
;
offset
=
buflen
+
crlf_len
-
1
;
...
...
@@ -2478,7 +2480,7 @@ static DWORD read_reply( struct request *request )
{
WCHAR
*
tmp
;
len
*=
2
;
if
(
!
(
tmp
=
heap_
realloc
(
raw_headers
,
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
tmp
=
realloc
(
raw_headers
,
len
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
request
->
raw_headers
=
raw_headers
=
tmp
;
}
if
(
!*
buffer
)
...
...
@@ -2524,10 +2526,10 @@ static DWORD get_redirect_url( struct request *request, WCHAR **ret_url, DWORD *
ret
=
query_headers
(
request
,
WINHTTP_QUERY_LOCATION
,
NULL
,
NULL
,
&
size
,
NULL
);
if
(
ret
!=
ERROR_INSUFFICIENT_BUFFER
)
return
ret
;
if
(
!
(
url
=
heap_
alloc
(
size
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
url
=
m
alloc
(
size
)))
return
ERROR_OUTOFMEMORY
;
if
((
ret
=
query_headers
(
request
,
WINHTTP_QUERY_LOCATION
,
NULL
,
url
,
&
size
,
NULL
)))
{
heap_
free
(
url
);
free
(
url
);
return
ret
;
}
*
ret_url
=
url
;
...
...
@@ -2557,7 +2559,7 @@ static DWORD handle_redirect( struct request *request, DWORD status )
ret
=
ERROR_OUTOFMEMORY
;
if
(
location
[
0
]
==
'/'
)
{
if
(
!
(
path
=
heap_
alloc
(
(
len_loc
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
end
;
if
(
!
(
path
=
m
alloc
(
(
len_loc
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
end
;
memcpy
(
path
,
location
,
len_loc
*
sizeof
(
WCHAR
)
);
path
[
len_loc
]
=
0
;
}
...
...
@@ -2565,13 +2567,13 @@ static DWORD handle_redirect( struct request *request, DWORD status )
{
if
((
p
=
wcsrchr
(
request
->
path
,
'/'
)))
*
p
=
0
;
len
=
lstrlenW
(
request
->
path
)
+
1
+
len_loc
;
if
(
!
(
path
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
end
;
if
(
!
(
path
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
end
;
lstrcpyW
(
path
,
request
->
path
);
lstrcatW
(
path
,
L"/"
);
memcpy
(
path
+
lstrlenW
(
path
),
location
,
len_loc
*
sizeof
(
WCHAR
)
);
path
[
len_loc
]
=
0
;
}
heap_
free
(
request
->
path
);
free
(
request
->
path
);
request
->
path
=
path
;
send_callback
(
&
request
->
hdr
,
WINHTTP_CALLBACK_STATUS_REDIRECT
,
location
,
len_loc
+
1
);
...
...
@@ -2597,7 +2599,7 @@ static DWORD handle_redirect( struct request *request, DWORD status )
send_callback
(
&
request
->
hdr
,
WINHTTP_CALLBACK_STATUS_REDIRECT
,
location
,
len_loc
+
1
);
len
=
uc
.
dwHostNameLength
;
if
(
!
(
hostname
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
hostname
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
ret
=
ERROR_OUTOFMEMORY
;
goto
end
;
...
...
@@ -2608,7 +2610,7 @@ static DWORD handle_redirect( struct request *request, DWORD status )
port
=
uc
.
nPort
?
uc
.
nPort
:
(
uc
.
nScheme
==
INTERNET_SCHEME_HTTPS
?
443
:
80
);
if
(
wcsicmp
(
connect
->
hostname
,
hostname
)
||
connect
->
serverport
!=
port
)
{
heap_
free
(
connect
->
hostname
);
free
(
connect
->
hostname
);
connect
->
hostname
=
hostname
;
connect
->
hostport
=
port
;
if
(
!
set_server_for_hostname
(
connect
,
hostname
,
port
))
...
...
@@ -2623,17 +2625,17 @@ static DWORD handle_redirect( struct request *request, DWORD status )
request
->
read_pos
=
request
->
read_size
=
0
;
request
->
read_chunked
=
request
->
read_chunked_eof
=
FALSE
;
}
else
heap_
free
(
hostname
);
else
free
(
hostname
);
if
((
ret
=
add_host_header
(
request
,
WINHTTP_ADDREQ_FLAG_ADD
|
WINHTTP_ADDREQ_FLAG_REPLACE
)))
goto
end
;
if
((
ret
=
open_connection
(
request
)))
goto
end
;
heap_
free
(
request
->
path
);
free
(
request
->
path
);
request
->
path
=
NULL
;
if
(
uc
.
dwUrlPathLength
)
{
len
=
uc
.
dwUrlPathLength
+
uc
.
dwExtraInfoLength
;
if
(
!
(
request
->
path
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
end
;
if
(
!
(
request
->
path
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
end
;
memcpy
(
request
->
path
,
uc
.
lpszUrlPath
,
(
len
+
1
)
*
sizeof
(
WCHAR
)
);
request
->
path
[
len
]
=
0
;
}
...
...
@@ -2646,14 +2648,14 @@ static DWORD handle_redirect( struct request *request, DWORD status )
if
(
status
!=
HTTP_STATUS_REDIRECT_KEEP_VERB
&&
!
wcscmp
(
request
->
verb
,
L"POST"
))
{
heap_
free
(
request
->
verb
);
free
(
request
->
verb
);
request
->
verb
=
strdupW
(
L"GET"
);
request
->
optional
=
NULL
;
request
->
optional_len
=
0
;
}
end:
heap_
free
(
location
);
free
(
location
);
return
ret
;
}
...
...
@@ -2764,7 +2766,7 @@ static void CALLBACK task_receive_response( TP_CALLBACK_INSTANCE *instance, void
receive_response
(
r
->
request
,
TRUE
);
release_object
(
&
r
->
request
->
hdr
);
heap_
free
(
r
);
free
(
r
);
}
/***********************************************************************
...
...
@@ -2793,14 +2795,14 @@ BOOL WINAPI WinHttpReceiveResponse( HINTERNET hrequest, LPVOID reserved )
{
struct
receive_response
*
r
;
if
(
!
(
r
=
heap_
alloc
(
sizeof
(
*
r
)
)))
return
FALSE
;
if
(
!
(
r
=
m
alloc
(
sizeof
(
*
r
)
)))
return
FALSE
;
r
->
request
=
request
;
addref_object
(
&
request
->
hdr
);
if
((
ret
=
queue_task
(
&
request
->
queue
,
task_receive_response
,
r
)))
{
release_object
(
&
request
->
hdr
);
heap_
free
(
r
);
free
(
r
);
}
}
else
ret
=
receive_response
(
request
,
FALSE
);
...
...
@@ -2851,7 +2853,7 @@ static void CALLBACK task_query_data_available( TP_CALLBACK_INSTANCE *instance,
query_data_available
(
q
->
request
,
q
->
available
,
TRUE
);
release_object
(
&
q
->
request
->
hdr
);
heap_
free
(
q
);
free
(
q
);
}
/***********************************************************************
...
...
@@ -2880,7 +2882,7 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
{
struct
query_data
*
q
;
if
(
!
(
q
=
heap_
alloc
(
sizeof
(
*
q
)
)))
return
FALSE
;
if
(
!
(
q
=
m
alloc
(
sizeof
(
*
q
)
)))
return
FALSE
;
q
->
request
=
request
;
q
->
available
=
available
;
...
...
@@ -2888,7 +2890,7 @@ BOOL WINAPI WinHttpQueryDataAvailable( HINTERNET hrequest, LPDWORD available )
if
((
ret
=
queue_task
(
&
request
->
queue
,
task_query_data_available
,
q
)))
{
release_object
(
&
request
->
hdr
);
heap_
free
(
q
);
free
(
q
);
}
}
else
ret
=
query_data_available
(
request
,
available
,
FALSE
);
...
...
@@ -2906,7 +2908,7 @@ static void CALLBACK task_read_data( TP_CALLBACK_INSTANCE *instance, void *ctx,
read_data
(
r
->
request
,
r
->
buffer
,
r
->
to_read
,
r
->
read
,
TRUE
);
release_object
(
&
r
->
request
->
hdr
);
heap_
free
(
r
);
free
(
r
);
}
/***********************************************************************
...
...
@@ -2935,7 +2937,7 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
{
struct
read_data
*
r
;
if
(
!
(
r
=
heap_
alloc
(
sizeof
(
*
r
)
)))
return
FALSE
;
if
(
!
(
r
=
m
alloc
(
sizeof
(
*
r
)
)))
return
FALSE
;
r
->
request
=
request
;
r
->
buffer
=
buffer
;
r
->
to_read
=
to_read
;
...
...
@@ -2945,7 +2947,7 @@ BOOL WINAPI WinHttpReadData( HINTERNET hrequest, LPVOID buffer, DWORD to_read, L
if
((
ret
=
queue_task
(
&
request
->
queue
,
task_read_data
,
r
)))
{
release_object
(
&
request
->
hdr
);
heap_
free
(
r
);
free
(
r
);
}
}
else
ret
=
read_data
(
request
,
buffer
,
to_read
,
read
,
FALSE
);
...
...
@@ -2985,7 +2987,7 @@ static void CALLBACK task_write_data( TP_CALLBACK_INSTANCE *instance, void *ctx,
write_data
(
w
->
request
,
w
->
buffer
,
w
->
to_write
,
w
->
written
,
TRUE
);
release_object
(
&
w
->
request
->
hdr
);
heap_
free
(
w
);
free
(
w
);
}
/***********************************************************************
...
...
@@ -3014,7 +3016,7 @@ BOOL WINAPI WinHttpWriteData( HINTERNET hrequest, LPCVOID buffer, DWORD to_write
{
struct
write_data
*
w
;
if
(
!
(
w
=
heap_
alloc
(
sizeof
(
*
w
)
)))
return
FALSE
;
if
(
!
(
w
=
m
alloc
(
sizeof
(
*
w
)
)))
return
FALSE
;
w
->
request
=
request
;
w
->
buffer
=
buffer
;
w
->
to_write
=
to_write
;
...
...
@@ -3024,7 +3026,7 @@ BOOL WINAPI WinHttpWriteData( HINTERNET hrequest, LPCVOID buffer, DWORD to_write
if
((
ret
=
queue_task
(
&
request
->
queue
,
task_write_data
,
w
)))
{
release_object
(
&
request
->
hdr
);
heap_
free
(
w
);
free
(
w
);
}
}
else
ret
=
write_data
(
request
,
buffer
,
to_write
,
written
,
FALSE
);
...
...
@@ -3051,7 +3053,7 @@ static void socket_destroy( struct object_header *hdr )
stop_queue
(
&
socket
->
recv_q
);
release_object
(
&
socket
->
request
->
hdr
);
heap_
free
(
socket
);
free
(
socket
);
}
static
BOOL
socket_set_option
(
struct
object_header
*
hdr
,
DWORD
option
,
void
*
buffer
,
DWORD
buflen
)
...
...
@@ -3087,7 +3089,7 @@ HINTERNET WINAPI WinHttpWebSocketCompleteUpgrade( HINTERNET hrequest, DWORD_PTR
SetLastError
(
ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
);
return
NULL
;
}
if
(
!
(
socket
=
heap_alloc_zero
(
sizeof
(
struct
socket
)
)))
if
(
!
(
socket
=
calloc
(
1
,
sizeof
(
*
socket
)
)))
{
release_object
(
&
request
->
hdr
);
return
NULL
;
...
...
@@ -3234,7 +3236,7 @@ static void CALLBACK task_socket_send( TP_CALLBACK_INSTANCE *instance, void *ctx
socket_send
(
s
->
socket
,
s
->
type
,
s
->
buf
,
s
->
len
,
TRUE
);
release_object
(
&
s
->
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
DWORD
WINAPI
WinHttpWebSocketSend
(
HINTERNET
hsocket
,
WINHTTP_WEB_SOCKET_BUFFER_TYPE
type
,
void
*
buf
,
DWORD
len
)
...
...
@@ -3267,7 +3269,7 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_
{
struct
socket_send
*
s
;
if
(
!
(
s
=
heap_
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
if
(
!
(
s
=
m
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
s
->
socket
=
socket
;
s
->
type
=
type
;
s
->
buf
=
buf
;
...
...
@@ -3277,7 +3279,7 @@ DWORD WINAPI WinHttpWebSocketSend( HINTERNET hsocket, WINHTTP_WEB_SOCKET_BUFFER_
if
((
ret
=
queue_task
(
&
socket
->
send_q
,
task_socket_send
,
s
)))
{
release_object
(
&
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
}
else
ret
=
socket_send
(
socket
,
type
,
buf
,
len
,
FALSE
);
...
...
@@ -3350,7 +3352,7 @@ static void CALLBACK task_socket_send_pong( TP_CALLBACK_INSTANCE *instance, void
send_frame
(
s
->
socket
->
request
->
netconn
,
SOCKET_OPCODE_PONG
,
0
,
NULL
,
0
,
TRUE
);
release_object
(
&
s
->
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
static
DWORD
socket_send_pong
(
struct
socket
*
socket
)
...
...
@@ -3360,14 +3362,14 @@ static DWORD socket_send_pong( struct socket *socket )
struct
socket_send
*
s
;
DWORD
ret
;
if
(
!
(
s
=
heap_
alloc
(
sizeof
(
*
s
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
s
=
m
alloc
(
sizeof
(
*
s
)
)))
return
ERROR_OUTOFMEMORY
;
s
->
socket
=
socket
;
addref_object
(
&
socket
->
hdr
);
if
((
ret
=
queue_task
(
&
socket
->
send_q
,
task_socket_send_pong
,
s
)))
{
release_object
(
&
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
return
ret
;
}
...
...
@@ -3484,7 +3486,7 @@ static void CALLBACK task_socket_receive( TP_CALLBACK_INSTANCE *instance, void *
socket_receive
(
r
->
socket
,
r
->
buf
,
r
->
len
,
NULL
,
NULL
,
TRUE
);
release_object
(
&
r
->
socket
->
hdr
);
heap_
free
(
r
);
free
(
r
);
}
DWORD
WINAPI
WinHttpWebSocketReceive
(
HINTERNET
hsocket
,
void
*
buf
,
DWORD
len
,
DWORD
*
ret_len
,
...
...
@@ -3513,7 +3515,7 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D
{
struct
socket_receive
*
r
;
if
(
!
(
r
=
heap_
alloc
(
sizeof
(
*
r
)
)))
return
FALSE
;
if
(
!
(
r
=
m
alloc
(
sizeof
(
*
r
)
)))
return
FALSE
;
r
->
socket
=
socket
;
r
->
buf
=
buf
;
r
->
len
=
len
;
...
...
@@ -3522,7 +3524,7 @@ DWORD WINAPI WinHttpWebSocketReceive( HINTERNET hsocket, void *buf, DWORD len, D
if
((
ret
=
queue_task
(
&
socket
->
recv_q
,
task_socket_receive
,
r
)))
{
release_object
(
&
socket
->
hdr
);
heap_
free
(
r
);
free
(
r
);
}
}
else
ret
=
socket_receive
(
socket
,
buf
,
len
,
ret_len
,
ret_type
,
FALSE
);
...
...
@@ -3564,7 +3566,7 @@ static void CALLBACK task_socket_shutdown( TP_CALLBACK_INSTANCE *instance, void
TRACE
(
"running %p
\n
"
,
work
);
release_object
(
&
s
->
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
DWORD
WINAPI
WinHttpWebSocketShutdown
(
HINTERNET
hsocket
,
USHORT
status
,
void
*
reason
,
DWORD
len
)
...
...
@@ -3592,7 +3594,7 @@ DWORD WINAPI WinHttpWebSocketShutdown( HINTERNET hsocket, USHORT status, void *r
{
struct
socket_shutdown
*
s
;
if
(
!
(
s
=
heap_
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
if
(
!
(
s
=
m
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
s
->
socket
=
socket
;
s
->
status
=
status
;
memcpy
(
s
->
reason
,
reason
,
len
);
...
...
@@ -3602,7 +3604,7 @@ DWORD WINAPI WinHttpWebSocketShutdown( HINTERNET hsocket, USHORT status, void *r
if
((
ret
=
queue_task
(
&
socket
->
send_q
,
task_socket_shutdown
,
s
)))
{
release_object
(
&
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
}
else
ret
=
socket_shutdown
(
socket
,
status
,
reason
,
len
,
FALSE
);
...
...
@@ -3666,7 +3668,7 @@ static void CALLBACK task_socket_close( TP_CALLBACK_INSTANCE *instance, void *ct
TRACE
(
"running %p
\n
"
,
work
);
release_object
(
&
s
->
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
DWORD
WINAPI
WinHttpWebSocketClose
(
HINTERNET
hsocket
,
USHORT
status
,
void
*
reason
,
DWORD
len
)
...
...
@@ -3694,7 +3696,7 @@ DWORD WINAPI WinHttpWebSocketClose( HINTERNET hsocket, USHORT status, void *reas
{
struct
socket_shutdown
*
s
;
if
(
!
(
s
=
heap_
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
if
(
!
(
s
=
m
alloc
(
sizeof
(
*
s
)
)))
return
FALSE
;
s
->
socket
=
socket
;
s
->
status
=
status
;
memcpy
(
s
->
reason
,
reason
,
len
);
...
...
@@ -3704,7 +3706,7 @@ DWORD WINAPI WinHttpWebSocketClose( HINTERNET hsocket, USHORT status, void *reas
if
((
ret
=
queue_task
(
&
socket
->
recv_q
,
task_socket_close
,
s
)))
{
release_object
(
&
socket
->
hdr
);
heap_
free
(
s
);
free
(
s
);
}
}
else
ret
=
socket_close
(
socket
,
status
,
reason
,
len
,
FALSE
);
...
...
@@ -3827,10 +3829,10 @@ static void free_request( struct winhttp_request *request )
CloseHandle
(
request
->
done
);
CloseHandle
(
request
->
wait
);
CloseHandle
(
request
->
cancel
);
heap_
free
(
request
->
proxy
.
lpszProxy
);
heap_
free
(
request
->
proxy
.
lpszProxyBypass
);
heap_
free
(
request
->
buffer
);
heap_
free
(
request
->
verb
);
free
(
request
->
proxy
.
lpszProxy
);
free
(
request
->
proxy
.
lpszProxyBypass
);
free
(
request
->
buffer
);
free
(
request
->
verb
);
VariantClear
(
&
request
->
data
);
}
...
...
@@ -3849,7 +3851,7 @@ static ULONG WINAPI winhttp_request_Release(
LeaveCriticalSection
(
&
request
->
cs
);
request
->
cs
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
request
->
cs
);
heap_
free
(
request
);
free
(
request
);
}
return
refs
;
}
...
...
@@ -4074,16 +4076,16 @@ static HRESULT WINAPI winhttp_request_SetProxy(
{
case
HTTPREQUEST_PROXYSETTING_DEFAULT
:
request
->
proxy
.
dwAccessType
=
WINHTTP_ACCESS_TYPE_DEFAULT_PROXY
;
heap_
free
(
request
->
proxy
.
lpszProxy
);
heap_
free
(
request
->
proxy
.
lpszProxyBypass
);
free
(
request
->
proxy
.
lpszProxy
);
free
(
request
->
proxy
.
lpszProxyBypass
);
request
->
proxy
.
lpszProxy
=
NULL
;
request
->
proxy
.
lpszProxyBypass
=
NULL
;
break
;
case
HTTPREQUEST_PROXYSETTING_DIRECT
:
request
->
proxy
.
dwAccessType
=
WINHTTP_ACCESS_TYPE_NO_PROXY
;
heap_
free
(
request
->
proxy
.
lpszProxy
);
heap_
free
(
request
->
proxy
.
lpszProxyBypass
);
free
(
request
->
proxy
.
lpszProxy
);
free
(
request
->
proxy
.
lpszProxyBypass
);
request
->
proxy
.
lpszProxy
=
NULL
;
request
->
proxy
.
lpszProxyBypass
=
NULL
;
break
;
...
...
@@ -4092,12 +4094,12 @@ static HRESULT WINAPI winhttp_request_SetProxy(
request
->
proxy
.
dwAccessType
=
WINHTTP_ACCESS_TYPE_NAMED_PROXY
;
if
(
V_VT
(
&
proxy_server
)
==
VT_BSTR
)
{
heap_
free
(
request
->
proxy
.
lpszProxy
);
free
(
request
->
proxy
.
lpszProxy
);
request
->
proxy
.
lpszProxy
=
strdupW
(
V_BSTR
(
&
proxy_server
)
);
}
if
(
V_VT
(
&
bypass_list
)
==
VT_BSTR
)
{
heap_
free
(
request
->
proxy
.
lpszProxyBypass
);
free
(
request
->
proxy
.
lpszProxyBypass
);
request
->
proxy
.
lpszProxyBypass
=
strdupW
(
V_BSTR
(
&
bypass_list
)
);
}
break
;
...
...
@@ -4169,9 +4171,9 @@ static void reset_request( struct winhttp_request *request )
request
->
hrequest
=
NULL
;
WinHttpCloseHandle
(
request
->
hconnect
);
request
->
hconnect
=
NULL
;
heap_
free
(
request
->
buffer
);
free
(
request
->
buffer
);
request
->
buffer
=
NULL
;
heap_
free
(
request
->
verb
);
free
(
request
->
verb
);
request
->
verb
=
NULL
;
request
->
offset
=
0
;
request
->
bytes_available
=
0
;
...
...
@@ -4184,9 +4186,9 @@ static void reset_request( struct winhttp_request *request )
request
->
send_timeout
=
30000
;
request
->
receive_timeout
=
30000
;
request
->
url_codepage
=
CP_UTF8
;
heap_
free
(
request
->
proxy
.
lpszProxy
);
free
(
request
->
proxy
.
lpszProxy
);
request
->
proxy
.
lpszProxy
=
NULL
;
heap_
free
(
request
->
proxy
.
lpszProxyBypass
);
free
(
request
->
proxy
.
lpszProxyBypass
);
request
->
proxy
.
lpszProxyBypass
=
NULL
;
VariantClear
(
&
request
->
data
);
request
->
state
=
REQUEST_STATE_INITIALIZED
;
...
...
@@ -4222,11 +4224,11 @@ static HRESULT WINAPI winhttp_request_Open(
EnterCriticalSection
(
&
request
->
cs
);
reset_request
(
request
);
if
(
!
(
hostname
=
heap_
alloc
(
(
uc
.
dwHostNameLength
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
error
;
if
(
!
(
hostname
=
m
alloc
(
(
uc
.
dwHostNameLength
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
error
;
memcpy
(
hostname
,
uc
.
lpszHostName
,
uc
.
dwHostNameLength
*
sizeof
(
WCHAR
)
);
hostname
[
uc
.
dwHostNameLength
]
=
0
;
if
(
!
(
path
=
heap_
alloc
(
(
uc
.
dwUrlPathLength
+
uc
.
dwExtraInfoLength
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
error
;
if
(
!
(
path
=
m
alloc
(
(
uc
.
dwUrlPathLength
+
uc
.
dwExtraInfoLength
+
1
)
*
sizeof
(
WCHAR
)
)))
goto
error
;
memcpy
(
path
,
uc
.
lpszUrlPath
,
(
uc
.
dwUrlPathLength
+
uc
.
dwExtraInfoLength
)
*
sizeof
(
WCHAR
)
);
path
[
uc
.
dwUrlPathLength
+
uc
.
dwExtraInfoLength
]
=
0
;
...
...
@@ -4270,17 +4272,17 @@ static HRESULT WINAPI winhttp_request_Open(
request
->
state
=
REQUEST_STATE_OPEN
;
request
->
verb
=
verb
;
heap_
free
(
hostname
);
heap_
free
(
path
);
free
(
hostname
);
free
(
path
);
LeaveCriticalSection
(
&
request
->
cs
);
return
S_OK
;
error:
WinHttpCloseHandle
(
request
->
hconnect
);
request
->
hconnect
=
NULL
;
heap_
free
(
hostname
);
heap_
free
(
path
);
heap_
free
(
verb
);
free
(
hostname
);
free
(
path
);
free
(
verb
);
LeaveCriticalSection
(
&
request
->
cs
);
return
HRESULT_FROM_WIN32
(
err
);
}
...
...
@@ -4311,7 +4313,7 @@ static HRESULT WINAPI winhttp_request_SetRequestHeader(
}
len
=
lstrlenW
(
header
)
+
4
;
if
(
value
)
len
+=
lstrlenW
(
value
);
if
(
!
(
str
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
str
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
err
=
ERROR_OUTOFMEMORY
;
goto
done
;
...
...
@@ -4322,7 +4324,7 @@ static HRESULT WINAPI winhttp_request_SetRequestHeader(
{
err
=
GetLastError
();
}
heap_
free
(
str
);
free
(
str
);
done:
LeaveCriticalSection
(
&
request
->
cs
);
...
...
@@ -4480,7 +4482,7 @@ static HRESULT request_receive( struct winhttp_request *request )
request
->
state
=
REQUEST_STATE_RESPONSE_RECEIVED
;
return
S_OK
;
}
if
(
!
(
request
->
buffer
=
heap_
alloc
(
buflen
)))
return
E_OUTOFMEMORY
;
if
(
!
(
request
->
buffer
=
m
alloc
(
buflen
)))
return
E_OUTOFMEMORY
;
request
->
buffer
[
0
]
=
0
;
size
=
0
;
do
...
...
@@ -4498,7 +4500,7 @@ static HRESULT request_receive( struct winhttp_request *request )
{
char
*
tmp
;
while
(
buflen
<
size
)
buflen
*=
2
;
if
(
!
(
tmp
=
heap_
realloc
(
request
->
buffer
,
buflen
)))
if
(
!
(
tmp
=
realloc
(
request
->
buffer
,
buflen
)))
{
err
=
ERROR_OUTOFMEMORY
;
goto
error
;
...
...
@@ -4520,7 +4522,7 @@ static HRESULT request_receive( struct winhttp_request *request )
return
S_OK
;
error:
heap_
free
(
request
->
buffer
);
free
(
request
->
buffer
);
request
->
buffer
=
NULL
;
return
HRESULT_FROM_WIN32
(
err
);
}
...
...
@@ -4584,7 +4586,7 @@ static HRESULT request_send( struct winhttp_request *request )
}
}
size
=
WideCharToMultiByte
(
cp
,
0
,
str
,
len
,
NULL
,
0
,
NULL
,
NULL
);
if
(
!
(
ptr
=
heap_
alloc
(
size
)))
return
E_OUTOFMEMORY
;
if
(
!
(
ptr
=
m
alloc
(
size
)))
return
E_OUTOFMEMORY
;
WideCharToMultiByte
(
cp
,
0
,
str
,
len
,
ptr
,
size
,
NULL
,
NULL
);
if
(
cp
==
CP_UTF8
)
request_set_utf8_content_type
(
request
);
}
...
...
@@ -4608,13 +4610,13 @@ static HRESULT request_send( struct winhttp_request *request )
}
if
((
err
=
wait_for_completion
(
request
)))
goto
error
;
if
(
sa
)
SafeArrayUnaccessData
(
sa
);
else
heap_
free
(
ptr
);
else
free
(
ptr
);
request
->
state
=
REQUEST_STATE_SENT
;
return
S_OK
;
error:
if
(
sa
)
SafeArrayUnaccessData
(
sa
);
else
heap_
free
(
ptr
);
else
free
(
ptr
);
return
HRESULT_FROM_WIN32
(
err
);
}
...
...
@@ -4776,7 +4778,7 @@ static DWORD request_get_codepage( struct winhttp_request *request, UINT *codepa
if
(
!
WinHttpQueryHeaders
(
request
->
hrequest
,
WINHTTP_QUERY_CONTENT_TYPE
,
NULL
,
NULL
,
&
size
,
NULL
)
&&
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
)
{
if
(
!
(
buffer
=
heap_
alloc
(
size
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
buffer
=
m
alloc
(
size
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
WinHttpQueryHeaders
(
request
->
hrequest
,
WINHTTP_QUERY_CONTENT_TYPE
,
NULL
,
buffer
,
&
size
,
NULL
))
{
return
GetLastError
();
...
...
@@ -4791,7 +4793,7 @@ static DWORD request_get_codepage( struct winhttp_request *request, UINT *codepa
if
(
!
wcsicmp
(
p
,
L"utf-8"
))
*
codepage
=
CP_UTF8
;
}
}
heap_
free
(
buffer
);
free
(
buffer
);
}
return
ERROR_SUCCESS
;
}
...
...
@@ -4920,8 +4922,8 @@ static ULONG WINAPI stream_Release( IStream *iface )
LONG
refs
=
InterlockedDecrement
(
&
stream
->
refs
);
if
(
!
refs
)
{
heap_
free
(
stream
->
data
);
heap_
free
(
stream
);
free
(
stream
->
data
);
free
(
stream
);
}
return
refs
;
}
...
...
@@ -5051,16 +5053,16 @@ static HRESULT WINAPI winhttp_request_get_ResponseStream(
err
=
ERROR_WINHTTP_CANNOT_CALL_BEFORE_SEND
;
goto
done
;
}
if
(
!
(
stream
=
heap_
alloc
(
sizeof
(
*
stream
)
)))
if
(
!
(
stream
=
m
alloc
(
sizeof
(
*
stream
)
)))
{
err
=
ERROR_OUTOFMEMORY
;
goto
done
;
}
stream
->
IStream_iface
.
lpVtbl
=
&
stream_vtbl
;
stream
->
refs
=
1
;
if
(
!
(
stream
->
data
=
heap_
alloc
(
request
->
offset
)))
if
(
!
(
stream
->
data
=
m
alloc
(
request
->
offset
)))
{
heap_
free
(
stream
);
free
(
stream
);
err
=
ERROR_OUTOFMEMORY
;
goto
done
;
}
...
...
@@ -5287,7 +5289,7 @@ HRESULT WinHttpRequest_create( void **obj )
TRACE
(
"%p
\n
"
,
obj
);
if
(
!
(
request
=
heap_alloc_zero
(
sizeof
(
*
request
)
)))
return
E_OUTOFMEMORY
;
if
(
!
(
request
=
calloc
(
1
,
sizeof
(
*
request
)
)))
return
E_OUTOFMEMORY
;
request
->
IWinHttpRequest_iface
.
lpVtbl
=
&
winhttp_request_vtbl
;
request
->
refs
=
1
;
InitializeCriticalSection
(
&
request
->
cs
);
...
...
dlls/winhttp/session.c
View file @
4f961d9e
...
...
@@ -74,12 +74,12 @@ static void session_destroy( struct object_header *hdr )
session
->
cs
.
DebugInfo
->
Spare
[
0
]
=
0
;
DeleteCriticalSection
(
&
session
->
cs
);
heap_
free
(
session
->
agent
);
heap_
free
(
session
->
proxy_server
);
heap_
free
(
session
->
proxy_bypass
);
heap_
free
(
session
->
proxy_username
);
heap_
free
(
session
->
proxy_password
);
heap_
free
(
session
);
free
(
session
->
agent
);
free
(
session
->
proxy_server
);
free
(
session
->
proxy_bypass
);
free
(
session
->
proxy_username
);
free
(
session
->
proxy_password
);
free
(
session
);
}
static
BOOL
session_query_option
(
struct
object_header
*
hdr
,
DWORD
option
,
void
*
buffer
,
DWORD
*
buflen
)
...
...
@@ -239,7 +239,7 @@ HINTERNET WINAPI WinHttpOpen( LPCWSTR agent, DWORD access, LPCWSTR proxy, LPCWST
TRACE
(
"%s, %u, %s, %s, 0x%08x
\n
"
,
debugstr_w
(
agent
),
access
,
debugstr_w
(
proxy
),
debugstr_w
(
bypass
),
flags
);
if
(
!
(
session
=
heap_alloc_zero
(
sizeof
(
struct
session
)
)))
return
NULL
;
if
(
!
(
session
=
calloc
(
1
,
sizeof
(
*
session
)
)))
return
NULL
;
session
->
hdr
.
type
=
WINHTTP_HANDLE_TYPE_SESSION
;
session
->
hdr
.
vtbl
=
&
session_vtbl
;
...
...
@@ -299,11 +299,11 @@ static void connect_destroy( struct object_header *hdr )
release_object
(
&
connect
->
session
->
hdr
);
heap_
free
(
connect
->
hostname
);
heap_
free
(
connect
->
servername
);
heap_
free
(
connect
->
username
);
heap_
free
(
connect
->
password
);
heap_
free
(
connect
);
free
(
connect
->
hostname
);
free
(
connect
->
servername
);
free
(
connect
->
username
);
free
(
connect
->
password
);
free
(
connect
);
}
static
BOOL
connect_query_option
(
struct
object_header
*
hdr
,
DWORD
option
,
void
*
buffer
,
DWORD
*
buflen
)
...
...
@@ -462,16 +462,14 @@ BOOL set_server_for_hostname( struct connect *connect, const WCHAR *server, INTE
if
(
!
connect
->
servername
||
wcsnicmp
(
connect
->
servername
,
session
->
proxy_server
,
colon
-
session
->
proxy_server
-
1
))
{
heap_
free
(
connect
->
servername
);
free
(
connect
->
servername
);
connect
->
resolved
=
FALSE
;
if
(
!
(
connect
->
servername
=
heap_alloc
(
(
colon
-
session
->
proxy_server
+
1
)
*
sizeof
(
WCHAR
)
)))
if
(
!
(
connect
->
servername
=
malloc
(
(
colon
-
session
->
proxy_server
+
1
)
*
sizeof
(
WCHAR
)
)))
{
ret
=
FALSE
;
goto
end
;
}
memcpy
(
connect
->
servername
,
session
->
proxy_server
,
(
colon
-
session
->
proxy_server
)
*
sizeof
(
WCHAR
)
);
memcpy
(
connect
->
servername
,
session
->
proxy_server
,
(
colon
-
session
->
proxy_server
)
*
sizeof
(
WCHAR
)
);
connect
->
servername
[
colon
-
session
->
proxy_server
]
=
0
;
if
(
*
(
colon
+
1
))
connect
->
serverport
=
wcstol
(
colon
+
1
,
NULL
,
10
);
...
...
@@ -481,10 +479,9 @@ BOOL set_server_for_hostname( struct connect *connect, const WCHAR *server, INTE
}
else
{
if
(
!
connect
->
servername
||
wcsicmp
(
connect
->
servername
,
session
->
proxy_server
))
if
(
!
connect
->
servername
||
wcsicmp
(
connect
->
servername
,
session
->
proxy_server
))
{
heap_
free
(
connect
->
servername
);
free
(
connect
->
servername
);
connect
->
resolved
=
FALSE
;
if
(
!
(
connect
->
servername
=
strdupW
(
session
->
proxy_server
)))
{
...
...
@@ -497,7 +494,7 @@ BOOL set_server_for_hostname( struct connect *connect, const WCHAR *server, INTE
}
else
if
(
server
)
{
heap_
free
(
connect
->
servername
);
free
(
connect
->
servername
);
connect
->
resolved
=
FALSE
;
if
(
!
(
connect
->
servername
=
strdupW
(
server
)))
{
...
...
@@ -537,7 +534,7 @@ HINTERNET WINAPI WinHttpConnect( HINTERNET hsession, LPCWSTR server, INTERNET_PO
SetLastError
(
ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
);
return
NULL
;
}
if
(
!
(
connect
=
heap_alloc_zero
(
sizeof
(
struct
connect
)
)))
if
(
!
(
connect
=
calloc
(
1
,
sizeof
(
*
connect
)
)))
{
release_object
(
&
session
->
hdr
);
return
NULL
;
...
...
@@ -588,27 +585,27 @@ static void request_destroy( struct object_header *hdr )
destroy_authinfo
(
request
->
authinfo
);
destroy_authinfo
(
request
->
proxy_authinfo
);
heap_
free
(
request
->
verb
);
heap_
free
(
request
->
path
);
heap_
free
(
request
->
version
);
heap_
free
(
request
->
raw_headers
);
heap_
free
(
request
->
status_text
);
free
(
request
->
verb
);
free
(
request
->
path
);
free
(
request
->
version
);
free
(
request
->
raw_headers
);
free
(
request
->
status_text
);
for
(
i
=
0
;
i
<
request
->
num_headers
;
i
++
)
{
heap_
free
(
request
->
headers
[
i
].
field
);
heap_
free
(
request
->
headers
[
i
].
value
);
free
(
request
->
headers
[
i
].
field
);
free
(
request
->
headers
[
i
].
value
);
}
heap_
free
(
request
->
headers
);
free
(
request
->
headers
);
for
(
i
=
0
;
i
<
TARGET_MAX
;
i
++
)
{
for
(
j
=
0
;
j
<
SCHEME_MAX
;
j
++
)
{
heap_
free
(
request
->
creds
[
i
][
j
].
username
);
heap_
free
(
request
->
creds
[
i
][
j
].
password
);
free
(
request
->
creds
[
i
][
j
].
username
);
free
(
request
->
creds
[
i
][
j
].
password
);
}
}
heap_
free
(
request
);
free
(
request
);
}
static
void
str_to_buffer
(
WCHAR
*
buffer
,
const
WCHAR
*
str
,
LPDWORD
buflen
)
...
...
@@ -835,7 +832,7 @@ static BOOL request_query_option( struct object_header *hdr, DWORD option, void
static
WCHAR
*
buffer_to_str
(
WCHAR
*
buffer
,
DWORD
buflen
)
{
WCHAR
*
ret
;
if
((
ret
=
heap_
alloc
(
(
buflen
+
1
)
*
sizeof
(
WCHAR
))))
if
((
ret
=
m
alloc
(
(
buflen
+
1
)
*
sizeof
(
WCHAR
))))
{
memcpy
(
ret
,
buffer
,
buflen
*
sizeof
(
WCHAR
)
);
ret
[
buflen
]
=
0
;
...
...
@@ -950,7 +947,7 @@ static BOOL request_set_option( struct object_header *hdr, DWORD option, void *b
{
struct
connect
*
connect
=
request
->
connect
;
heap_
free
(
connect
->
username
);
free
(
connect
->
username
);
if
(
!
(
connect
->
username
=
buffer_to_str
(
buffer
,
buflen
)))
return
FALSE
;
return
TRUE
;
}
...
...
@@ -958,7 +955,7 @@ static BOOL request_set_option( struct object_header *hdr, DWORD option, void *b
{
struct
connect
*
connect
=
request
->
connect
;
heap_
free
(
connect
->
password
);
free
(
connect
->
password
);
if
(
!
(
connect
->
password
=
buffer_to_str
(
buffer
,
buflen
)))
return
FALSE
;
return
TRUE
;
}
...
...
@@ -966,7 +963,7 @@ static BOOL request_set_option( struct object_header *hdr, DWORD option, void *b
{
struct
session
*
session
=
request
->
connect
->
session
;
heap_
free
(
session
->
proxy_username
);
free
(
session
->
proxy_username
);
if
(
!
(
session
->
proxy_username
=
buffer_to_str
(
buffer
,
buflen
)))
return
FALSE
;
return
TRUE
;
}
...
...
@@ -974,7 +971,7 @@ static BOOL request_set_option( struct object_header *hdr, DWORD option, void *b
{
struct
session
*
session
=
request
->
connect
->
session
;
heap_
free
(
session
->
proxy_password
);
free
(
session
->
proxy_password
);
if
(
!
(
session
->
proxy_password
=
buffer_to_str
(
buffer
,
buflen
)))
return
FALSE
;
return
TRUE
;
}
...
...
@@ -1077,7 +1074,7 @@ static WCHAR *get_request_path( const WCHAR *object )
WCHAR
*
p
,
*
ret
;
if
(
!
object
||
object
[
0
]
!=
'/'
)
len
++
;
if
(
!
(
p
=
ret
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
!
(
p
=
ret
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
!
object
||
object
[
0
]
!=
'/'
)
*
p
++
=
'/'
;
if
(
object
)
lstrcpyW
(
p
,
object
);
ret
[
len
]
=
0
;
...
...
@@ -1115,7 +1112,7 @@ HINTERNET WINAPI WinHttpOpenRequest( HINTERNET hconnect, LPCWSTR verb, LPCWSTR o
SetLastError
(
ERROR_WINHTTP_INCORRECT_HANDLE_TYPE
);
return
NULL
;
}
if
(
!
(
request
=
heap_alloc_zero
(
sizeof
(
struct
request
)
)))
if
(
!
(
request
=
calloc
(
1
,
sizeof
(
*
request
)
)))
{
release_object
(
&
connect
->
hdr
);
return
NULL
;
...
...
@@ -1306,16 +1303,16 @@ static IP_ADAPTER_ADDRESSES *get_adapters(void)
GAA_FLAG_SKIP_DNS_SERVER
|
GAA_FLAG_SKIP_FRIENDLY_NAME
;
IP_ADAPTER_ADDRESSES
*
tmp
,
*
ret
;
if
(
!
(
ret
=
heap_
alloc
(
size
)))
return
NULL
;
if
(
!
(
ret
=
m
alloc
(
size
)))
return
NULL
;
err
=
GetAdaptersAddresses
(
AF_UNSPEC
,
flags
,
NULL
,
ret
,
&
size
);
while
(
err
==
ERROR_BUFFER_OVERFLOW
)
{
if
(
!
(
tmp
=
heap_
realloc
(
ret
,
size
)))
break
;
if
(
!
(
tmp
=
realloc
(
ret
,
size
)))
break
;
ret
=
tmp
;
err
=
GetAdaptersAddresses
(
AF_UNSPEC
,
flags
,
NULL
,
ret
,
&
size
);
}
if
(
err
==
ERROR_SUCCESS
)
return
ret
;
heap_
free
(
ret
);
free
(
ret
);
return
NULL
;
}
...
...
@@ -1345,12 +1342,12 @@ static WCHAR *detect_autoproxyconfig_url_dhcp(void)
/* FIXME: also skip adapters where DHCP is disabled */
size
=
256
;
if
(
!
(
buf
=
heap_
alloc
(
size
)))
goto
done
;
if
(
!
(
buf
=
m
alloc
(
size
)))
goto
done
;
err
=
DhcpRequestParams
(
DHCPCAPI_REQUEST_SYNCHRONOUS
,
NULL
,
name
,
NULL
,
send_params
,
recv_params
,
buf
,
&
size
,
NULL
);
while
(
err
==
ERROR_MORE_DATA
)
{
if
(
!
(
tmp
=
heap_
realloc
(
buf
,
size
)))
goto
done
;
if
(
!
(
tmp
=
realloc
(
buf
,
size
)))
goto
done
;
buf
=
tmp
;
err
=
DhcpRequestParams
(
DHCPCAPI_REQUEST_SYNCHRONOUS
,
NULL
,
name
,
NULL
,
send_params
,
recv_params
,
buf
,
&
size
,
NULL
);
...
...
@@ -1358,7 +1355,7 @@ static WCHAR *detect_autoproxyconfig_url_dhcp(void)
if
(
err
==
ERROR_SUCCESS
&&
param
.
nBytesData
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
(
const
char
*
)
param
.
Data
,
param
.
nBytesData
,
NULL
,
0
);
if
((
ret
=
heap_
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
if
((
ret
=
m
alloc
(
(
len
+
1
)
*
sizeof
(
WCHAR
)
)))
{
MultiByteToWideChar
(
CP_ACP
,
0
,
(
const
char
*
)
param
.
Data
,
param
.
nBytesData
,
ret
,
len
);
ret
[
len
]
=
0
;
...
...
@@ -1369,8 +1366,8 @@ static WCHAR *detect_autoproxyconfig_url_dhcp(void)
}
done:
heap_
free
(
buf
);
heap_
free
(
adapters
);
free
(
buf
);
free
(
adapters
);
return
ret
;
}
...
...
@@ -1381,10 +1378,10 @@ static char *get_computer_name( COMPUTER_NAME_FORMAT format )
GetComputerNameExA
(
format
,
NULL
,
&
size
);
if
(
GetLastError
()
!=
ERROR_MORE_DATA
)
return
NULL
;
if
(
!
(
ret
=
heap_
alloc
(
size
)))
return
NULL
;
if
(
!
(
ret
=
m
alloc
(
size
)))
return
NULL
;
if
(
!
GetComputerNameExA
(
format
,
ret
,
&
size
))
{
heap_
free
(
ret
);
free
(
ret
);
return
NULL
;
}
return
ret
;
...
...
@@ -1432,7 +1429,7 @@ static WCHAR *detect_autoproxyconfig_url_dns(void)
if
(
!
(
fqdn
=
get_computer_name
(
ComputerNamePhysicalDnsFullyQualified
)))
return
NULL
;
if
(
!
(
domain
=
get_computer_name
(
ComputerNamePhysicalDnsDomain
)))
{
heap_
free
(
fqdn
);
free
(
fqdn
);
return
NULL
;
}
p
=
fqdn
;
...
...
@@ -1442,10 +1439,10 @@ static WCHAR *detect_autoproxyconfig_url_dns(void)
struct
addrinfo
*
ai
;
int
res
;
if
(
!
(
name
=
heap_
alloc
(
sizeof
(
"wpad"
)
+
strlen
(
p
)
)))
if
(
!
(
name
=
m
alloc
(
sizeof
(
"wpad"
)
+
strlen
(
p
)
)))
{
heap_
free
(
fqdn
);
heap_
free
(
domain
);
free
(
fqdn
);
free
(
domain
);
return
NULL
;
}
strcpy
(
name
,
"wpad"
);
...
...
@@ -1458,15 +1455,15 @@ static WCHAR *detect_autoproxyconfig_url_dns(void)
if
(
ret
)
{
TRACE
(
"returning %s
\n
"
,
debugstr_w
(
ret
));
heap_
free
(
name
);
free
(
name
);
break
;
}
}
heap_
free
(
name
);
free
(
name
);
p
++
;
}
heap_
free
(
domain
);
heap_
free
(
fqdn
);
free
(
domain
);
free
(
fqdn
);
return
ret
;
}
...
...
@@ -1547,7 +1544,7 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
if
(
!
l
&&
type
==
REG_BINARY
&&
size
>=
sizeof
(
struct
connection_settings_header
)
+
2
*
sizeof
(
DWORD
))
{
BYTE
*
buf
=
heap_
alloc
(
size
);
BYTE
*
buf
=
m
alloc
(
size
);
if
(
buf
)
{
...
...
@@ -1605,7 +1602,7 @@ BOOL WINAPI WinHttpGetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
}
}
}
heap_
free
(
buf
);
free
(
buf
);
}
}
RegCloseKey
(
key
);
...
...
@@ -1673,7 +1670,7 @@ BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser( WINHTTP_CURRENT_USER_IE_PROXY
ret
=
TRUE
;
goto
done
;
}
if
(
!
(
hdr
=
heap_
alloc
(
size
)))
goto
done
;
if
(
!
(
hdr
=
m
alloc
(
size
)))
goto
done
;
if
(
RegQueryValueExW
(
hkey
,
L"DefaultConnectionSettings"
,
NULL
,
&
type
,
(
BYTE
*
)
hdr
,
&
size
)
||
hdr
->
magic
!=
WININET_SETTINGS_MAGIC
)
{
...
...
@@ -1713,7 +1710,7 @@ BOOL WINAPI WinHttpGetIEProxyConfigForCurrentUser( WINHTTP_CURRENT_USER_IE_PROXY
done:
RegCloseKey
(
hkey
);
heap_
free
(
hdr
);
free
(
hdr
);
if
(
!
ret
)
{
GlobalFree
(
config
->
lpszAutoConfigUrl
);
...
...
@@ -1777,7 +1774,7 @@ static char *download_script( const WCHAR *url, DWORD *out_size )
uc
.
dwHostNameLength
=
-
1
;
uc
.
dwUrlPathLength
=
-
1
;
if
(
!
WinHttpCrackUrl
(
url
,
0
,
0
,
&
uc
))
return
NULL
;
if
(
!
(
hostname
=
heap_
alloc
(
(
uc
.
dwHostNameLength
+
1
)
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
!
(
hostname
=
m
alloc
(
(
uc
.
dwHostNameLength
+
1
)
*
sizeof
(
WCHAR
)
)))
return
NULL
;
memcpy
(
hostname
,
uc
.
lpszHostName
,
uc
.
dwHostNameLength
*
sizeof
(
WCHAR
)
);
hostname
[
uc
.
dwHostNameLength
]
=
0
;
...
...
@@ -1792,7 +1789,7 @@ static char *download_script( const WCHAR *url, DWORD *out_size )
&
size
,
NULL
)
||
status
!=
HTTP_STATUS_OK
)
goto
done
;
size
=
4096
;
if
(
!
(
buffer
=
heap_
alloc
(
size
)))
goto
done
;
if
(
!
(
buffer
=
m
alloc
(
size
)))
goto
done
;
to_read
=
size
;
offset
=
0
;
for
(;;)
...
...
@@ -1806,7 +1803,7 @@ static char *download_script( const WCHAR *url, DWORD *out_size )
{
to_read
=
size
;
size
*=
2
;
if
(
!
(
tmp
=
heap_
realloc
(
buffer
,
size
)))
goto
done
;
if
(
!
(
tmp
=
realloc
(
buffer
,
size
)))
goto
done
;
buffer
=
tmp
;
}
}
...
...
@@ -1815,7 +1812,7 @@ done:
WinHttpCloseHandle
(
req
);
WinHttpCloseHandle
(
con
);
WinHttpCloseHandle
(
ses
);
heap_
free
(
hostname
);
free
(
hostname
);
if
(
!
buffer
)
SetLastError
(
ERROR_WINHTTP_UNABLE_TO_DOWNLOAD_SCRIPT
);
return
buffer
;
}
...
...
@@ -1846,7 +1843,7 @@ static BOOL run_script( char *script, DWORD size, const WCHAR *url, WINHTTP_PROX
if
(
!
(
urlA
=
strdupWA
(
url
)))
return
FALSE
;
if
(
!
(
ret
=
InternetInitializeAutoProxyDll
(
0
,
NULL
,
NULL
,
NULL
,
&
buffer
)))
{
heap_
free
(
urlA
);
free
(
urlA
);
return
FALSE
;
}
...
...
@@ -1862,12 +1859,12 @@ static BOOL run_script( char *script, DWORD size, const WCHAR *url, WINHTTP_PROX
hostnameA
,
strlen
(
hostnameA
),
&
result
,
&
len_result
)))
{
ret
=
parse_script_result
(
result
,
info
);
heap_
free
(
result
);
free
(
result
);
}
heap_
free
(
hostnameA
);
free
(
hostnameA
);
}
heap_
free
(
urlA
);
free
(
urlA
);
InternetDeInitializeAutoProxyDll
(
NULL
,
0
);
return
ret
;
}
...
...
@@ -1918,7 +1915,7 @@ BOOL WINAPI WinHttpGetProxyForUrl( HINTERNET hsession, LPCWSTR url, WINHTTP_AUTO
if
((
script
=
download_script
(
pac_url
,
&
size
)))
{
ret
=
run_script
(
script
,
size
,
url
,
info
);
heap_
free
(
script
);
free
(
script
);
}
done:
...
...
@@ -1990,8 +1987,7 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
if
(
info
->
lpszProxyBypass
)
size
+=
lstrlenW
(
info
->
lpszProxyBypass
);
}
buf
=
heap_alloc
(
size
);
if
(
buf
)
if
((
buf
=
malloc
(
size
)))
{
struct
connection_settings_header
*
hdr
=
(
struct
connection_settings_header
*
)
buf
;
...
...
@@ -2028,7 +2024,7 @@ BOOL WINAPI WinHttpSetDefaultProxyConfiguration( WINHTTP_PROXY_INFO *info )
l
=
RegSetValueExW
(
key
,
L"WinHttpSettings"
,
0
,
REG_BINARY
,
buf
,
size
);
if
(
!
l
)
ret
=
TRUE
;
heap_
free
(
buf
);
free
(
buf
);
}
RegCloseKey
(
key
);
}
...
...
dlls/winhttp/url.c
View file @
4f961d9e
...
...
@@ -65,7 +65,7 @@ static WCHAR *decode_url( LPCWSTR url, DWORD *len )
const
WCHAR
*
p
=
url
;
WCHAR
hex
[
3
],
*
q
,
*
ret
;
if
(
!
(
ret
=
heap_
alloc
(
*
len
*
sizeof
(
WCHAR
)
)))
return
NULL
;
if
(
!
(
ret
=
m
alloc
(
*
len
*
sizeof
(
WCHAR
)
)))
return
NULL
;
q
=
ret
;
while
(
*
len
>
0
)
{
...
...
@@ -144,7 +144,7 @@ static DWORD escape_url( const WCHAR *url, DWORD *len, WCHAR **ret )
len_path
=
0
;
}
if
(
!
(
*
ret
=
heap_
alloc
(
(
len_base
+
len_path
+
1
)
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
if
(
!
(
*
ret
=
m
alloc
(
(
len_base
+
len_path
+
1
)
*
sizeof
(
WCHAR
)
)))
return
ERROR_OUTOFMEMORY
;
memcpy
(
*
ret
,
url
,
len_base
*
sizeof
(
WCHAR
)
);
if
(
p
)
escape_string
(
p
,
*
len
-
(
p
-
url
),
*
ret
+
len_base
,
&
len_path
);
...
...
@@ -331,8 +331,8 @@ exit:
if
(
overflow
)
err
=
ERROR_INSUFFICIENT_BUFFER
;
uc
->
nScheme
=
scheme_number
;
}
heap_
free
(
url_decoded
);
heap_
free
(
url_escaped
);
free
(
url_decoded
);
free
(
url_escaped
);
SetLastError
(
err
);
return
!
err
;
}
...
...
dlls/winhttp/winhttp_private.h
View file @
4f961d9e
...
...
@@ -19,13 +19,12 @@
#ifndef _WINE_WINHTTP_PRIVATE_H_
#define _WINE_WINHTTP_PRIVATE_H_
#include "wine/heap.h"
#include "wine/list.h"
#include "ole2.h"
#include "sspi.h"
#include "wincrypt.h"
#include "wine/list.h"
#define WINHTTP_HANDLE_TYPE_SOCKET 4
struct
object_header
;
...
...
@@ -347,17 +346,12 @@ 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
void
*
__WINE_ALLOC_SIZE
(
2
)
heap_realloc_zero
(
LPVOID
mem
,
SIZE_T
size
)
{
return
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
mem
,
size
);
}
static
inline
WCHAR
*
strdupW
(
const
WCHAR
*
src
)
{
WCHAR
*
dst
;
if
(
!
src
)
return
NULL
;
dst
=
heap_
alloc
(
(
lstrlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
)
);
dst
=
m
alloc
(
(
lstrlenW
(
src
)
+
1
)
*
sizeof
(
WCHAR
)
);
if
(
dst
)
lstrcpyW
(
dst
,
src
);
return
dst
;
}
...
...
@@ -368,7 +362,7 @@ static inline WCHAR *strdupAW( const char *src )
if
(
src
)
{
int
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
NULL
,
0
);
if
((
dst
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
)
)))
if
((
dst
=
m
alloc
(
len
*
sizeof
(
WCHAR
)
)))
MultiByteToWideChar
(
CP_ACP
,
0
,
src
,
-
1
,
dst
,
len
);
}
return
dst
;
...
...
@@ -380,7 +374,7 @@ static inline char *strdupWA( const WCHAR *src )
if
(
src
)
{
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
-
1
,
NULL
,
0
,
NULL
,
NULL
);
if
((
dst
=
heap_
alloc
(
len
)))
if
((
dst
=
m
alloc
(
len
)))
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
-
1
,
dst
,
len
,
NULL
,
NULL
);
}
return
dst
;
...
...
@@ -392,7 +386,7 @@ static inline char *strdupWA_sized( const WCHAR *src, DWORD size )
if
(
src
)
{
int
len
=
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
size
,
NULL
,
0
,
NULL
,
NULL
)
+
1
;
if
((
dst
=
heap_
alloc
(
len
)))
if
((
dst
=
m
alloc
(
len
)))
{
WideCharToMultiByte
(
CP_ACP
,
0
,
src
,
size
,
dst
,
len
,
NULL
,
NULL
);
dst
[
len
-
1
]
=
0
;
...
...
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