kernel32: WideCharToMultiByte: return error on negative dest len (take 2)

Dan Kegel dank at kegel.com
Wed Mar 26 08:31:31 CDT 2008


On Wed, Mar 26, 2008 at 4:04 AM, Michael Stefaniuc <mstefani at redhat.com> wrote:
>  > This would require reviewing all uses of WideCharToMultiByte in Wine,
>  > many places get this wrong. Unless you have an app that requires this
>  > fix I'd suggest to leave the test as todo_wine for now.
>
>  Would that be a good janitorial work to be done before Wine 1.0? I feel
>  like I'm getting tired of translating ...

Sure.  A quick grep finds some obvious ones:

$ find . -name '*.c' | xargs grep WideCharToMultiByte | grep ' -1, NULL, NULL)'
./wininet/urlcache.c:        WideCharToMultiByte(CP_ACP, 0,
lpszLocalFileName, -1, achFile, -1, NULL, NULL);
./mshtml/editor.c:        WideCharToMultiByte(CP_ACP, 0, V_BSTR(in),
-1, stra, -1, NULL, NULL);
./mshtml/persist.c:            WideCharToMultiByte(CP_ACP, 0, headers,
-1, data, -1, NULL, NULL);
./mshtml/install.c:    WideCharToMultiByte(CP_ACP, 0, file_name, -1,
file_name_a, -1, NULL, NULL);
./mshtml/nsio.c:            WideCharToMultiByte(CP_ACP, 0,
container->doc->mime, -1, This->content, -1, NULL, NULL);
./mshtml/navigate.c:        WideCharToMultiByte(CP_ACP, 0,
szStatusText, -1, This->nschannel->content, -1, NULL, NULL);
./advapi32/cred.c:        string_len = WideCharToMultiByte(CP_ACP, 0,
CredentialW->TargetName, -1, CredentialA->TargetName, -1, NULL, NULL);
./advapi32/cred.c:        string_len = WideCharToMultiByte(CP_ACP, 0,
CredentialW->Comment, -1, CredentialA->Comment, -1, NULL, NULL);
./advapi32/cred.c:        string_len = WideCharToMultiByte(CP_ACP, 0,
CredentialW->TargetAlias, -1, CredentialA->TargetAlias, -1, NULL,
NULL);
./advapi32/cred.c:        string_len = WideCharToMultiByte(CP_ACP, 0,
CredentialW->UserName, -1, CredentialA->UserName, -1, NULL, NULL);
./urlmon/sec_mgr.c:    WideCharToMultiByte(CP_ACP, 0, url, -1,
(LPSTR)pbSecurityId, -1, NULL, NULL)

(I peeked at that last one.  The code is enforcing the length limit itself and
then telling WideCharToMultiByte that there's no limit.  May as well
pass the proper
limit to WideCharToMultiByte and let it do the length checking?)

The first step, as Alexandre says, is to add the test with a todo_wine
around the negative destlen test.
I would have done it but I'm more than happy to let you run with it.

I haven't quite figured out the fix for bug 9039, this is just something
I noticed along the way.
- Dan



More information about the wine-devel mailing list