Lei Zhang : wininet: Work around NULL headers when handling HTTP_QUERY_RAW_HEADERS_CRLF.
Alexandre Julliard
julliard at winehq.org
Thu Aug 28 07:00:36 CDT 2008
Module: wine
Branch: master
Commit: bc9e214f6fb2ea68c9fcd7f635c47f3e85fc695c
URL: http://source.winehq.org/git/wine.git/?a=commit;h=bc9e214f6fb2ea68c9fcd7f635c47f3e85fc695c
Author: Lei Zhang <thestig at google.com>
Date: Wed Aug 27 16:54:17 2008 -0700
wininet: Work around NULL headers when handling HTTP_QUERY_RAW_HEADERS_CRLF.
---
dlls/wininet/http.c | 15 ++++++++++++---
dlls/wininet/tests/http.c | 10 ++++++++++
2 files changed, 22 insertions(+), 3 deletions(-)
diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index 4630f3b..b8ecb47 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -2187,15 +2187,18 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev
case HTTP_QUERY_RAW_HEADERS_CRLF:
{
LPWSTR headers;
- DWORD len;
+ DWORD len = 0;
BOOL ret = FALSE;
+ static const WCHAR CRLF[] = {'\r','\n',0};
if (request_only)
headers = HTTP_BuildHeaderRequestString(lpwhr, lpwhr->lpszVerb, lpwhr->lpszPath, lpwhr->lpszVersion);
else
headers = lpwhr->lpszRawHeaders;
- len = strlenW(headers) * sizeof(WCHAR);
+ if (headers)
+ len = strlenW(headers) * sizeof(WCHAR);
+
if (len + sizeof(WCHAR) > *lpdwBufferLength)
{
len += sizeof(WCHAR);
@@ -2204,7 +2207,13 @@ static BOOL WINAPI HTTP_HttpQueryInfoW( LPWININETHTTPREQW lpwhr, DWORD dwInfoLev
}
else if (lpBuffer)
{
- memcpy(lpBuffer, headers, len + sizeof(WCHAR));
+ if (headers)
+ memcpy(lpBuffer, headers, len + sizeof(WCHAR));
+ else
+ {
+ len = strlenW(CRLF) * sizeof(WCHAR);
+ memcpy(lpBuffer, CRLF, sizeof(CRLF));
+ }
TRACE("returning data: %s\n", debugstr_wn(lpBuffer, len / sizeof(WCHAR)));
ret = TRUE;
}
diff --git a/dlls/wininet/tests/http.c b/dlls/wininet/tests/http.c
index 9ad6274..1c52f27 100644
--- a/dlls/wininet/tests/http.c
+++ b/dlls/wininet/tests/http.c
@@ -1208,6 +1208,16 @@ static void HttpHeaders_test(void)
/* end of W version tests */
+ /* Without HTTP_QUERY_FLAG_REQUEST_HEADERS */
+ index = 0;
+ len = sizeof(buffer);
+ memset(buffer, 'x', sizeof(buffer));
+ ok(HttpQueryInfo(hRequest,HTTP_QUERY_RAW_HEADERS_CRLF,
+ buffer,&len,&index) == TRUE,"Query failed\n");
+ ok(len == 2, "Expected 2, got %d\n", len);
+ ok(strcmp(buffer, "\r\n") == 0, "Expected CRLF, got '%s'\n", buffer);
+ ok(index == 0, "Index was incremented\n");
+
ok(HttpAddRequestHeaders(hRequest,"Warning:test2",-1,HTTP_ADDREQ_FLAG_ADD),
"Failed to add duplicate header using HTTP_ADDREQ_FLAG_ADD\n");
More information about the wine-cvs
mailing list