Commit 719cd82f authored by Rob Shearman's avatar Rob Shearman Committed by Alexandre Julliard

wininet: Fix potential buffer overrun in HttpQueryInfoA.

If HTTP_QUERY_CUSTOM is specified then the buffer contains a null-terminated string on input and data of length len on output. The code wasn't taking into account that the input len could be less than the length of the string and thus could result in the allocated buffer being overrun with the call to WideCharToMultiByte.
parent 39dce046
......@@ -1982,11 +1982,20 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
if (lpBuffer)
{
DWORD alloclen;
len = (*lpdwBufferLength)*sizeof(WCHAR);
bufferW = HeapAlloc( GetProcessHeap(), 0, len );
if ((dwInfoLevel & HTTP_QUERY_HEADER_MASK) == HTTP_QUERY_CUSTOM)
{
alloclen = MultiByteToWideChar( CP_ACP, 0, lpBuffer, -1, NULL, 0 ) * sizeof(WCHAR);
if (alloclen < len)
alloclen = len;
}
else
alloclen = len;
bufferW = HeapAlloc( GetProcessHeap(), 0, alloclen );
/* buffer is in/out because of HTTP_QUERY_CUSTOM */
if ((dwInfoLevel & HTTP_QUERY_HEADER_MASK) == HTTP_QUERY_CUSTOM)
MultiByteToWideChar(CP_ACP,0,lpBuffer,-1,bufferW,len);
MultiByteToWideChar( CP_ACP, 0, lpBuffer, -1, bufferW, alloclen / sizeof(WCHAR) );
} else
{
bufferW = NULL;
......
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