Commit a2bf4d00 authored by Alexandre Julliard's avatar Alexandre Julliard

Fixed length handling in HttpQueryInfoW.

parent 840d7de5
...@@ -953,9 +953,9 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, ...@@ -953,9 +953,9 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
} }
size += delim; size += delim;
if (size + 1 > *lpdwBufferLength) if (size + 1 > *lpdwBufferLength/sizeof(WCHAR))
{ {
*lpdwBufferLength = size + 1; *lpdwBufferLength = (size + 1) * sizeof(WCHAR);
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
goto lend; goto lend;
} }
...@@ -988,9 +988,9 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, ...@@ -988,9 +988,9 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
strcpyW((WCHAR*)lpBuffer + cnt, index == HTTP_QUERY_RAW_HEADERS_CRLF ? szcrlf : sznul); strcpyW((WCHAR*)lpBuffer + cnt, index == HTTP_QUERY_RAW_HEADERS_CRLF ? szcrlf : sznul);
*lpdwBufferLength = cnt + delim; *lpdwBufferLength = (cnt + delim) * sizeof(WCHAR);
bSuccess = TRUE; bSuccess = TRUE;
goto lend; goto lend;
} }
else if (index >= 0 && index <= HTTP_QUERY_MAX && lpwhr->StdHeaders[index].lpszValue) else if (index >= 0 && index <= HTTP_QUERY_MAX && lpwhr->StdHeaders[index].lpszValue)
{ {
...@@ -1055,18 +1055,17 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel, ...@@ -1055,18 +1055,17 @@ BOOL WINAPI HttpQueryInfoW(HINTERNET hHttpRequest, DWORD dwInfoLevel,
} }
else else
{ {
INT len = strlenW(lphttpHdr->lpszValue); INT len = (strlenW(lphttpHdr->lpszValue) + 1) * sizeof(WCHAR);
if (len + 1 > *lpdwBufferLength) if (len > *lpdwBufferLength)
{ {
*lpdwBufferLength = len + 1; *lpdwBufferLength = len;
INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER); INTERNET_SetLastError(ERROR_INSUFFICIENT_BUFFER);
goto lend; goto lend;
} }
strncpyW(lpBuffer, lphttpHdr->lpszValue, len); memcpy(lpBuffer, lphttpHdr->lpszValue, len);
((WCHAR*)lpBuffer)[len]=0; *lpdwBufferLength = len - sizeof(WCHAR);
*lpdwBufferLength = len;
bSuccess = TRUE; bSuccess = TRUE;
TRACE(" returning string : '%s'\n", debugstr_w(lpBuffer)); TRACE(" returning string : '%s'\n", debugstr_w(lpBuffer));
......
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