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
493b6915
Commit
493b6915
authored
May 07, 2008
by
Hans Leidekker
Committed by
Alexandre Julliard
May 07, 2008
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wininet: Deal with bogus accept types array passed into HttpOpenRequestA.
parent
3da466a9
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
55 additions
and
15 deletions
+55
-15
http.c
dlls/wininet/http.c
+29
-15
http.c
dlls/wininet/tests/http.c
+26
-0
No files found.
dlls/wininet/http.c
View file @
493b6915
...
...
@@ -964,9 +964,10 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
{
LPWSTR
szVerb
=
NULL
,
szObjectName
=
NULL
;
LPWSTR
szVersion
=
NULL
,
szReferrer
=
NULL
,
*
szAcceptTypes
=
NULL
;
INT
len
;
INT
acceptTypesCount
;
INT
len
,
acceptTypesCount
;
HINTERNET
rc
=
FALSE
;
LPCSTR
*
types
;
TRACE
(
"(%p, %s, %s, %s, %s, %p, %08x, %08lx)
\n
"
,
hHttpSession
,
debugstr_a
(
lpszVerb
),
debugstr_a
(
lpszObjectName
),
debugstr_a
(
lpszVersion
),
debugstr_a
(
lpszReferrer
),
lpszAcceptTypes
,
...
...
@@ -1008,24 +1009,37 @@ HINTERNET WINAPI HttpOpenRequestA(HINTERNET hHttpSession,
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszReferrer
,
-
1
,
szReferrer
,
len
);
}
acceptTypesCount
=
0
;
if
(
lpszAcceptTypes
)
{
/* find out how many there are */
while
(
lpszAcceptTypes
[
acceptTypesCount
]
&&
*
lpszAcceptTypes
[
acceptTypesCount
])
acceptTypesCount
++
;
acceptTypesCount
=
0
;
types
=
lpszAcceptTypes
;
while
(
*
types
)
{
/* find out how many there are */
if
(((
ULONG_PTR
)
*
types
>>
16
)
&&
**
types
)
{
TRACE
(
"accept type: %s
\n
"
,
debugstr_a
(
*
types
));
acceptTypesCount
++
;
}
types
++
;
}
szAcceptTypes
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
WCHAR
*
)
*
(
acceptTypesCount
+
1
));
if
(
!
szAcceptTypes
)
goto
end
;
acceptTypesCount
=
0
;
while
(
lpszAcceptTypes
[
acceptTypesCount
]
&&
*
lpszAcceptTypes
[
acceptTypesCount
])
types
=
lpszAcceptTypes
;
while
(
*
types
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszAcceptTypes
[
acceptTypesCount
],
-
1
,
NULL
,
0
);
szAcceptTypes
[
acceptTypesCount
]
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
if
(
!
szAcceptTypes
[
acceptTypesCount
]
)
goto
end
;
MultiByteToWideChar
(
CP_ACP
,
0
,
lpszAcceptTypes
[
acceptTypesCount
],
-
1
,
szAcceptTypes
[
acceptTypesCount
],
len
);
acceptTypesCount
++
;
if
(((
ULONG_PTR
)
*
types
>>
16
)
&&
**
types
)
{
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
*
types
,
-
1
,
NULL
,
0
);
szAcceptTypes
[
acceptTypesCount
]
=
HeapAlloc
(
GetProcessHeap
(),
0
,
len
*
sizeof
(
WCHAR
));
if
(
!
szAcceptTypes
[
acceptTypesCount
])
goto
end
;
MultiByteToWideChar
(
CP_ACP
,
0
,
*
types
,
-
1
,
szAcceptTypes
[
acceptTypesCount
],
len
);
acceptTypesCount
++
;
}
types
++
;
}
szAcceptTypes
[
acceptTypesCount
]
=
NULL
;
}
...
...
dlls/wininet/tests/http.c
View file @
493b6915
...
...
@@ -1746,6 +1746,31 @@ static void test_user_agent_header(void)
InternetCloseHandle
(
ses
);
}
static
void
test_bogus_accept_types_array
(
void
)
{
HINTERNET
ses
,
con
,
req
;
static
const
char
*
types
[]
=
{
(
const
char
*
)
6240
,
"*/*"
,
"%p"
,
""
,
"*/*"
,
NULL
};
DWORD
size
;
char
buffer
[
32
];
BOOL
ret
;
ses
=
InternetOpen
(
"MERONG(0.9/;p)"
,
INTERNET_OPEN_TYPE_DIRECT
,
""
,
""
,
0
);
con
=
InternetConnect
(
ses
,
"www.winehq.org"
,
80
,
NULL
,
NULL
,
INTERNET_SERVICE_HTTP
,
0
,
0
);
req
=
HttpOpenRequest
(
con
,
"POST"
,
"/post/post_action.php"
,
"HTTP/1.0"
,
""
,
types
,
INTERNET_FLAG_FORMS_SUBMIT
,
0
);
ok
(
req
!=
NULL
,
"HttpOpenRequest failed: %u
\n
"
,
GetLastError
());
buffer
[
0
]
=
0
;
size
=
sizeof
(
buffer
);
ret
=
HttpQueryInfo
(
req
,
HTTP_QUERY_ACCEPT
|
HTTP_QUERY_FLAG_REQUEST_HEADERS
,
buffer
,
&
size
,
NULL
);
ok
(
ret
,
"HttpQueryInfo failed: %u
\n
"
,
GetLastError
());
ok
(
!
strcmp
(
buffer
,
"*/*, %p, */*"
),
"got '%s' expected '*/*, %%p, */*'
\n
"
,
buffer
);
InternetCloseHandle
(
req
);
InternetCloseHandle
(
con
);
InternetCloseHandle
(
ses
);
}
#define STATUS_STRING(status) \
memcpy(status_string[status], #status, sizeof(CHAR) * \
(strlen(#status) < MAX_STATUS_NAME ? \
...
...
@@ -1821,4 +1846,5 @@ START_TEST(http)
HttpHeaders_test
();
test_http_connection
();
test_user_agent_header
();
test_bogus_accept_types_array
();
}
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