Fix the HttpQueryInfoA function buffer size.

This commit is contained in:
Mike McCormack 2004-03-30 20:37:49 +00:00 committed by Alexandre Julliard
parent 1cf04bd70a
commit 1baf39f95a
1 changed files with 17 additions and 9 deletions

View File

@ -774,7 +774,7 @@ HINTERNET WINAPI HTTP_HttpOpenRequestW(HINTERNET hHttpSession,
/***********************************************************************
* HttpQueryInfoA (WININET.@)
* HttpQueryInfoW (WININET.@)
*
* Queries for information about an HTTP request
*
@ -1091,20 +1091,28 @@ BOOL WINAPI HttpQueryInfoA(HINTERNET hHttpRequest, DWORD dwInfoLevel,
LPVOID lpBuffer, LPDWORD lpdwBufferLength, LPDWORD lpdwIndex)
{
BOOL result;
DWORD charLen=*lpdwBufferLength;
WCHAR* tempBuffer=HeapAlloc(GetProcessHeap(), 0, charLen);
result=HttpQueryInfoW(hHttpRequest, dwInfoLevel, tempBuffer, &charLen, lpdwIndex);
DWORD len;
WCHAR* bufferW;
if((dwInfoLevel & HTTP_QUERY_FLAG_NUMBER) ||
(dwInfoLevel & HTTP_QUERY_FLAG_SYSTEMTIME))
{
memcpy(lpBuffer,tempBuffer,charLen);
return HttpQueryInfoW( hHttpRequest, dwInfoLevel, lpBuffer,
lpdwBufferLength, lpdwIndex );
}
else
len = (*lpdwBufferLength)*sizeof(WCHAR);
bufferW = HeapAlloc( GetProcessHeap(), 0, len );
result = HttpQueryInfoW( hHttpRequest, dwInfoLevel, bufferW,
&len, lpdwIndex );
if( result )
{
int nChars=WideCharToMultiByte(CP_ACP,0, tempBuffer,charLen,lpBuffer,*lpdwBufferLength,NULL,NULL);
*lpdwBufferLength=nChars;
len = WideCharToMultiByte( CP_ACP,0, bufferW, len / sizeof(WCHAR),
lpBuffer, *lpdwBufferLength, NULL, NULL );
*lpdwBufferLength = len * sizeof(WCHAR);
}
HeapFree(GetProcessHeap(), 0, tempBuffer);
HeapFree(GetProcessHeap(), 0, bufferW );
return result;
}