WININET: take account of dwHeaderLength in HttpSendRequest

Mike McCormack mike at codeweavers.com
Tue Aug 3 05:11:41 CDT 2004


Some garbage characters were getting into the HTTP request if 
HttpSendRequest was called with a positive dwHeaderLength and a 
lpszRequest that was not nul terminated.

Mike


ChangeLog:
* take account of dwHeaderLength in HttpSendRequest
-------------- next part --------------
Index: dlls/wininet/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/http.c,v
retrieving revision 1.75
diff -u -r1.75 http.c
--- dlls/wininet/http.c	22 Jul 2004 20:36:36 -0000	1.75
+++ dlls/wininet/http.c	3 Aug 2004 08:51:24 -0000
@@ -1537,14 +1537,17 @@
         }
 
         /* add the headers the caller supplied */
-        if( lpszHeaders )
+        if( lpszHeaders && dwHeaderLength )
         {
-            len = strlenW(lpszHeaders)+3;
-            szCookedHeaders = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR)*len );
-            strcpyW( szCookedHeaders, lpszHeaders );
+            if( dwHeaderLength < 0 )
+                len = strlenW(lpszHeaders);
+            else
+                len = dwHeaderLength;
+            szCookedHeaders = HeapAlloc( GetProcessHeap(), 0, sizeof(WCHAR)*(len+1) );
+            strncpyW( szCookedHeaders, lpszHeaders, len );
 
-            /* make sure there's exactly one linebreak at the end of the string */
-            p = &szCookedHeaders[len-4];
+            /* make sure there's no linebreaks at the end of the string */
+            p = &szCookedHeaders[len-1];
             while( (szCookedHeaders <= p) && ((*p == '\n') || (*p == '\r')) )
                 p--;
             p[1] = 0;


More information about the wine-patches mailing list