shell32: Use simple helper for case insensitive strstr()

Nikolay Sivov nsivov at codeweavers.com
Thu Jan 26 02:12:54 CST 2012


On 1/25/2012 13:36, Alexandre Julliard wrote:
> Nikolay Sivov<nsivov at codeweavers.com>  writes:
>
>> Fix for http://bugs.winehq.org/show_bug.cgi?id=28087
> You shouldn't need anything of the kind. If StrStrIW doesn't work right
> it should be fixed (plus of course there's no reason to even use
> strstr() here at all).
When I debugged that I remember there's was a problem with 
CompareStringW() actually.
StrStrIW() eventually uses it like:
---
   iRet = CompareStringW(GetThreadLocale(), NORM_IGNORECASE, lpszStr, 
iLen, lpszComp, iLen);
---
so both strings are passed with the same length. CompareStringW() in 
turn uses winelib's wine_compare_string()
that tries to actualize passed string length look backwards from string 
tail searching for first not null - helper real_length().
So it easily gets past string data if specified length is large enough. 
Some tests show that CompareStringW()
survives in such case - it uses 'or' it seems, so it doesn't matter what 
happens first: a null terminator or consumed chars count.

So yeah, this probably should be fixed, but requires winelib changes and 
a test that will crash without a fix, not in very reliable way depending
on string length passed to it.

About avoiding strstr() at all, does this one look ok - 
http://bugs.winehq.org/attachment.cgi?id=38556 ?




More information about the wine-devel mailing list