Commit bc9e214f authored by Lei Zhang's avatar Lei Zhang Committed by Alexandre Julliard

wininet: Work around NULL headers when handling HTTP_QUERY_RAW_HEADERS_CRLF.

parent faf9c55e
......@@ -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;
}
......
......@@ -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");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment