WININET: fix the HttpQueryInfoA function buffer size

Mike McCormack mike at codeweavers.com
Tue Mar 30 00:30:10 CST 2004


ChangeLog:
* fix the HttpQueryInfoA function buffer size
-------------- next part --------------
Index: dlls/wininet/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/http.c,v
retrieving revision 1.54
diff -u -r1.54 http.c
--- dlls/wininet/http.c	30 Mar 2004 04:36:09 -0000	1.54
+++ dlls/wininet/http.c	30 Mar 2004 05:38:25 -0000
@@ -774,7 +774,7 @@
 
 
 /***********************************************************************
- *           HttpQueryInfoA (WININET.@)
+ *           HttpQueryInfoW (WININET.@)
  *
  * Queries for information about an HTTP request
  *
@@ -1091,20 +1091,28 @@
 	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,
+                                     lpBuffer, *lpdwBufferLength, NULL, NULL );
+        *lpdwBufferLength = len;
     }
-    HeapFree(GetProcessHeap(), 0, tempBuffer);
+    HeapFree(GetProcessHeap(), 0, bufferW );
+
     return result;
 }
 


More information about the wine-patches mailing list