HttpQueryInfoA Revisited
Robert Shearman
rob at codeweavers.com
Wed Jul 21 06:51:27 CDT 2004
Changelog:
HttpQueryInfo returns buffer length including null terminator on insufficient buffer length and buffer length excluding null terminator on success:
- Fix HTTP_HttpQueryInfoW for these semantics.
- Fix HttpQueryInfoA to correctly copy the null terminator in the call to WideCharToMultiByte.
-------------- next part --------------
Index: wine/dlls/wininet/http.c
===================================================================
RCS file: /home/wine/wine/dlls/wininet/http.c,v
retrieving revision 1.72
diff -u -r1.72 http.c
--- wine/dlls/wininet/http.c 20 Jul 2004 01:21:08 -0000 1.72
+++ wine/dlls/wininet/http.c 21 Jul 2004 11:46:39 -0000
@@ -862,7 +862,10 @@
return FALSE;
}
memcpy(lpBuffer, lpwhr->lpszRawHeaders, (len+1)*sizeof(WCHAR));
- *lpdwBufferLength = (len + 1) * sizeof(WCHAR);
+ *lpdwBufferLength = len * sizeof(WCHAR);
+
+ TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, len));
+
return TRUE;
}
else if (index == HTTP_QUERY_RAW_HEADERS)
@@ -894,7 +897,7 @@
TRACE("returning data: %s\n", debugstr_wn((WCHAR*)lpBuffer, size));
- *lpdwBufferLength = (size + 1) * sizeof(WCHAR);
+ *lpdwBufferLength = size * sizeof(WCHAR);
HTTP_FreeTokens(ppszRawHeaderLines);
return TRUE;
@@ -1160,16 +1163,18 @@
&len, lpdwIndex );
if( result )
{
- len = WideCharToMultiByte( CP_ACP,0, bufferW, len / sizeof(WCHAR),
- lpBuffer, *lpdwBufferLength, NULL, NULL );
- *lpdwBufferLength = len * sizeof(WCHAR);
+ len = WideCharToMultiByte( CP_ACP,0, bufferW, len / sizeof(WCHAR) + 1,
+ lpBuffer, *lpdwBufferLength + sizeof(char), NULL, NULL );
+ *lpdwBufferLength = len - sizeof(char);
+
+ TRACE("lpBuffer: %s\n", debugstr_a(lpBuffer));
}
else
/* since the strings being returned from HttpQueryInfoW should be
* only ASCII characters, it is reasonable to assume that all of
* the Unicode characters can be reduced to a single byte */
*lpdwBufferLength = len / sizeof(WCHAR);
-
+
HeapFree(GetProcessHeap(), 0, bufferW );
return result;
More information about the wine-patches
mailing list