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
96820142
Commit
96820142
authored
Sep 03, 2019
by
Daniel Lehman
Committed by
Alexandre Julliard
Sep 04, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Return error from HttpQueryInfo if number argument is invalid.
Signed-off-by:
Daniel Lehman
<
dlehman25@gmail.com
>
Signed-off-by:
Alexandre Julliard
<
julliard@winehq.org
>
parent
c5651e94
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
102 additions
and
3 deletions
+102
-3
http.c
dlls/wininet/http.c
+20
-3
http.c
dlls/wininet/tests/http.c
+82
-0
No files found.
dlls/wininet/http.c
View file @
96820142
...
...
@@ -42,6 +42,7 @@
#include <stdio.h>
#include <time.h>
#include <assert.h>
#include <errno.h>
#include "windef.h"
#include "winbase.h"
...
...
@@ -3724,9 +3725,25 @@ static DWORD HTTP_HttpQueryInfoW(http_request_t *request, DWORD dwInfoLevel,
/* coalesce value to requested type */
if
(
dwInfoLevel
&
HTTP_QUERY_FLAG_NUMBER
&&
lpBuffer
)
{
*
(
int
*
)
lpBuffer
=
atoiW
(
lphttpHdr
->
lpszValue
);
TRACE
(
" returning number: %d
\n
"
,
*
(
int
*
)
lpBuffer
);
}
unsigned
long
value
;
if
(
*
lpdwBufferLength
!=
sizeof
(
DWORD
))
{
LeaveCriticalSection
(
&
request
->
headers_section
);
return
ERROR_HTTP_INVALID_HEADER
;
}
errno
=
0
;
value
=
strtoulW
(
lphttpHdr
->
lpszValue
,
NULL
,
10
);
if
(
value
>
UINT_MAX
||
(
value
==
ULONG_MAX
&&
errno
==
ERANGE
))
{
LeaveCriticalSection
(
&
request
->
headers_section
);
return
ERROR_HTTP_INVALID_HEADER
;
}
*
(
DWORD
*
)
lpBuffer
=
value
;
TRACE
(
" returning number: %u
\n
"
,
*
(
DWORD
*
)
lpBuffer
);
}
else
if
(
dwInfoLevel
&
HTTP_QUERY_FLAG_SYSTEMTIME
&&
lpBuffer
)
{
time_t
tmpTime
;
...
...
dlls/wininet/tests/http.c
View file @
96820142
...
...
@@ -23,6 +23,7 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
#include "windef.h"
#include "winbase.h"
...
...
@@ -2061,6 +2062,12 @@ static const char okmsg2[] =
"Set-Cookie: two
\r\n
"
"
\r\n
"
;
static
DWORD64
content_length
;
static
const
char
largemsg
[]
=
"HTTP/1.1 200 OK
\r\n
"
"Content-Length: %I64u
\r\n
"
"
\r\n
"
;
static
const
char
notokmsg
[]
=
"HTTP/1.1 400 Bad Request
\r\n
"
"Server: winetest
\r\n
"
...
...
@@ -2455,6 +2462,12 @@ static DWORD CALLBACK server_thread(LPVOID param)
{
send
(
c
,
okmsg
,
sizeof
(
okmsg
)
-
1
,
0
);
}
if
(
strstr
(
buffer
,
"HEAD /test_large_content"
))
{
char
msg
[
sizeof
(
largemsg
)
+
16
];
sprintf
(
msg
,
largemsg
,
content_length
);
send
(
c
,
msg
,
strlen
(
msg
),
0
);
}
shutdown
(
c
,
2
);
closesocket
(
c
);
c
=
-
1
;
...
...
@@ -5515,6 +5528,74 @@ static void test_remove_dot_segments(int port)
close_request
(
&
req
);
}
struct
large_test
{
DWORD64
content_length
;
BOOL
ret
;
};
static
void
test_large_content
(
int
port
)
{
struct
large_test
tests
[]
=
{
{
0
,
TRUE
},
{
UINT_MAX
-
1
,
TRUE
},
{
UINT_MAX
,
TRUE
},
{
(
DWORD64
)
UINT_MAX
+
1
,
FALSE
},
{
~
0
,
FALSE
},
};
test_request_t
req
;
DWORD
sizelen
,
len
;
DWORD64
len64
;
BOOL
ret
;
size_t
i
;
open_simple_request
(
&
req
,
"localhost"
,
port
,
"HEAD"
,
"/test_large_content"
);
for
(
i
=
0
;
i
<
ARRAY_SIZE
(
tests
);
i
++
)
{
content_length
=
tests
[
i
].
content_length
;
ret
=
HttpSendRequestA
(
req
.
request
,
NULL
,
0
,
NULL
,
0
);
ok
(
ret
,
"HttpSendRequest failed: %u
\n
"
,
GetLastError
());
len
=
~
0
;
sizelen
=
sizeof
(
len
);
SetLastError
(
0xdeadbeef
);
ret
=
HttpQueryInfoA
(
req
.
request
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_CONTENT_LENGTH
,
&
len
,
&
sizelen
,
0
);
if
(
tests
[
i
].
ret
)
{
ok
(
ret
,
"HttpQueryInfo should have succeeded
\n
"
);
ok
(
GetLastError
()
==
ERROR_SUCCESS
||
broken
(
GetLastError
()
==
0xdeadbeef
),
/* xp, 2k8, vista */
"expected ERROR_SUCCESS, got %x
\n
"
,
GetLastError
());
ok
(
len
==
(
DWORD
)
tests
[
i
].
content_length
,
"expected %u, got %u
\n
"
,
(
DWORD
)
tests
[
i
].
content_length
,
len
);
}
else
{
ok
(
!
ret
,
"HttpQueryInfo should have failed
\n
"
);
ok
(
GetLastError
()
==
ERROR_HTTP_INVALID_HEADER
,
"expected ERROR_HTTP_INVALID_HEADER, got %x
\n
"
,
GetLastError
());
ok
(
len
==
~
0
,
"expected ~0, got %u
\n
"
,
len
);
}
ok
(
sizelen
==
sizeof
(
DWORD
),
"sizelen %u
\n
"
,
sizelen
);
}
/* test argument size */
len64
=
~
0
;
sizelen
=
sizeof
(
len64
);
SetLastError
(
0xdeadbeef
);
ret
=
HttpQueryInfoA
(
req
.
request
,
HTTP_QUERY_FLAG_NUMBER
|
HTTP_QUERY_CONTENT_LENGTH
,
&
len64
,
&
len
,
0
);
ok
(
!
ret
,
"HttpQueryInfo should have failed
\n
"
);
ok
(
GetLastError
()
==
ERROR_HTTP_INVALID_HEADER
,
"expected ERROR_HTTP_INVALID_HEADER, got %x
\n
"
,
GetLastError
());
ok
(
sizelen
==
sizeof
(
DWORD64
),
"sizelen %u
\n
"
,
sizelen
);
ok
(
len64
==
~
0
,
"len64 %x%08x
\n
"
,
(
DWORD
)(
len64
>>
32
),
(
DWORD
)
len64
);
close_request
(
&
req
);
}
static
void
test_http_connection
(
void
)
{
struct
server_info
si
;
...
...
@@ -5573,6 +5654,7 @@ static void test_http_connection(void)
test_redirect
(
si
.
port
);
test_persistent_connection
(
si
.
port
);
test_remove_dot_segments
(
si
.
port
);
test_large_content
(
si
.
port
);
/* send the basic request again to shutdown the server thread */
test_basic_request
(
si
.
port
,
"GET"
,
"/quit"
);
...
...
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