wcsxfrm() with empty locale crashes the runtime
Corinna Vinschen
corinna-cygwin@cygwin.com
Tue Mar 19 20:42:00 GMT 2019
On Mar 19 22:28, LRN wrote:
> The testcase is attached. Running it with Cygwin-i386 leads to a crash. My
> guess is that the implementation is not POSIX-conformant and tries to
> dereference the first argument (NULL), even though the third argument is 0.
>
> Tested with Cygwin-3.0.4.
> #include <wchar.h>
> #include <stdlib.h>
> #include <locale.h>
>
> int
> main ()
> {
> wchar_t w[2] = { L'z', L'\0' };
> setlocale (LC_ALL, "");
> int l = wcsxfrm (NULL, w, 0);
> return l;
> }
Thanks for the testcase. The problem has been introduced in commit
c0d7d3e1a2fa (*) when it turned out that combining the LCMAP_SORTKEY and
LCMAP_BYTEREV flags to LCMapStringW(**) were not such a good idea after
all. The fix at the time was to do the byte swap ourselves, but that
patch forgot to take a char count of 0 into account.
I pushed a patch and uploaded new developer snapshots to
https://cygwin.com/snapshots/
Pleas give them a try.
Thanks,
Corinna
(*) https://sourceware.org/git/gitweb.cgi?p=newlib-cygwin.git;a=commitdiff;h=c0d7d3e1a2fa
(**) https://docs.microsoft.com/en-us/windows/desktop/api/winnls/nf-winnls-lcmapstringex
--
Corinna Vinschen
Cygwin Maintainer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://cygwin.com/pipermail/cygwin/attachments/20190319/4b9c93ab/attachment.sig>
More information about the Cygwin
mailing list