[2/6] wininet: Avoid accessing uninitialized memory in HttpSendRequestExW.

Hans Leidekker hans at codeweavers.com
Tue Oct 27 04:03:36 CDT 2009


Found by valgrind.
---
 dlls/wininet/http.c |   12 ++++++++++--
 1 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/dlls/wininet/http.c b/dlls/wininet/http.c
index d8db8af..1426439 100644
--- a/dlls/wininet/http.c
+++ b/dlls/wininet/http.c
@@ -3338,8 +3338,16 @@ BOOL WINAPI HttpSendRequestExW(HINTERNET hRequest,
         req = &workRequest.u.HttpSendRequestW;
         if (lpBuffersIn)
         {
-            /* FIXME: this should use dwHeadersLength or may not be necessary at all */
-            req->lpszHeader = heap_strdupW(lpBuffersIn->lpcszHeader);
+            DWORD size;
+
+            if (lpBuffersIn->dwHeadersLength == ~0u)
+                size = (strlenW( lpBuffersIn->lpcszHeader ) + 1) * sizeof(WCHAR);
+            else
+                size = lpBuffersIn->dwHeadersLength * sizeof(WCHAR);
+
+            req->lpszHeader = HeapAlloc( GetProcessHeap(), 0, size );
+            memcpy( req->lpszHeader, lpBuffersIn->lpcszHeader, size );
+
             req->dwHeaderLength = lpBuffersIn->dwHeadersLength;
             req->lpOptional = lpBuffersIn->lpvBuffer;
             req->dwOptionalLength = lpBuffersIn->dwBufferLength;
-- 
1.6.3.3





More information about the wine-patches mailing list