This is the mail archive of the cygwin mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: wcsxfrm() with empty locale crashes the runtime


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

Attachment: signature.asc
Description: PGP signature


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]