[PATCH v3 0/1] MR8228: mshtml: Fix misuse of IWinInetHttpInfo_QueryInfo.
IWinInetHttpInfo_QueryInfo returns a multibyte string, not a wide string. We were also wrongly expecting it to have a NUL terminator. * * * this one doesn't feel good. IWinInetHttpInfo_QueryInfo calls HttpInfo_QueryInfo (urlmon), which calls HttpQueryInfoA (wininet), so it returns char*. but inside, HttpQueryInfoA is calling HttpQueryInfoW and does charset conversion. so we are converting the string to multibyte and back. maybe there's an API that returns wchar* i don't know about. -- v3: mshtml: Fix misuse of IWinInetHttpInfo_QueryInfo. https://gitlab.winehq.org/wine/wine/-/merge_requests/8228
From: Yuxuan Shui <yshui(a)codeweavers.com> IWinInetHttpInfo_QueryInfo returns a multibyte string, not a wide string. --- dlls/mshtml/navigate.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/dlls/mshtml/navigate.c b/dlls/mshtml/navigate.c index 6b5eff15105..90a3b4f5ca1 100644 --- a/dlls/mshtml/navigate.c +++ b/dlls/mshtml/navigate.c @@ -814,7 +814,8 @@ static void query_http_info(nsChannelBSC *This, IWinInetHttpInfo *wininet_info) { const WCHAR *ptr; DWORD len = 0; - WCHAR *buf; + WCHAR *wbuf; + char *buf; IWinInetHttpInfo_QueryInfo(wininet_info, HTTP_QUERY_RAW_HEADERS_CRLF, NULL, &len, NULL, NULL); if(!len) @@ -830,12 +831,13 @@ static void query_http_info(nsChannelBSC *This, IWinInetHttpInfo *wininet_info) return; } - ptr = wcschr(buf, '\r'); + wbuf = strdupAtoW(buf); + ptr = wcschr(wbuf, '\r'); if(ptr && ptr[1] == '\n') { ptr += 2; process_response_headers(This, ptr); } - + free(wbuf); free(buf); } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/8228
On Wed Jun 11 13:46:06 2025 +0000, Jacek Caban wrote:
As far as I can tell, the strings are null-terminated. It likely appeared otherwise because the code was treating them as wide-character strings. That part of the commit message is inaccurate and should be corrected. updated, i think this should address the problems you raised.
-- https://gitlab.winehq.org/wine/wine/-/merge_requests/8228#note_106334
participants (2)
-
Yuxuan Shui -
Yuxuan Shui (@yshui)