Wininet Buffer Length Fixes

Robert Shearman rob at codeweavers.com
Tue Jul 13 11:35:11 CDT 2004


Hi,

This patch fixes several places where the buffer length semantics were 
confused.
InternetGetCookieW returns the number of bytes *including* the 
terminating character.
HttpQueryInfoA also returns the number bytes, but it is not WCHARs. 
Also, pass NULL terminating character into WideCharToMultiByte so that 
the string is properly null-terminated, like the native version.

Rob

Changelog:
- InternetGetCookieW returns the number of bytes
- Fix the returned length from HttpQueryInfoA

-------------- next part --------------
Index: wine/dlls/wininet/cookie.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/cookie.c,v
retrieving revision 1.7
diff -u -r1.7 cookie.c
--- wine/dlls/wininet/cookie.c	19 Apr 2004 20:12:14 -0000	1.7
+++ wine/dlls/wininet/cookie.c	13 Jul 2004 16:23:10 -0000
@@ -390,7 +390,7 @@
     if (lpCookieData == NULL)
     {
 	cnt += 1; /* NULL */
-	*lpdwSize = cnt;
+	*lpdwSize = cnt*sizeof(WCHAR);
 	TRACE("returning\n");
 	return TRUE;
     }
@@ -398,7 +398,7 @@
     if (!domain_count)
         return FALSE;
 
-    *lpdwSize = cnt + 1;
+    *lpdwSize = (cnt + 1)*sizeof(WCHAR);
 
     TRACE("Returning %i (from %i domains): %s\n", cnt, domain_count,
            debugstr_w(lpCookieData));
Index: wine/dlls/wininet/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/http.c,v
retrieving revision 1.65
diff -u -r1.65 http.c
--- wine/dlls/wininet/http.c	4 Jul 2004 00:24:47 -0000	1.65
+++ wine/dlls/wininet/http.c	13 Jul 2004 16:23:11 -0000
@@ -1131,8 +1186,8 @@
     if( result )
     {
         len = WideCharToMultiByte( CP_ACP,0, bufferW, len / sizeof(WCHAR),
-                                     lpBuffer, *lpdwBufferLength, NULL, NULL );
-        *lpdwBufferLength = len * sizeof(WCHAR);
+                                     lpBuffer, *lpdwBufferLength+1, NULL, NULL );
+        *lpdwBufferLength = (len-1) * sizeof(CHAR);
     }
     HeapFree(GetProcessHeap(), 0, bufferW );
 


More information about the wine-patches mailing list