public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: LRN <lrn1986@gmail.com>
Cc: cygwin@cygwin.com
Subject: Re: wcsxfrm() with empty locale crashes the runtime
Date: Tue, 19 Mar 2019 20:42:00 -0000	[thread overview]
Message-ID: <20190319204247.GQ3908@calimero.vinschen.de> (raw)
In-Reply-To: <02f956fa-e872-87ba-9ab0-f10afc494a02@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 1219 bytes --]

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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

  reply	other threads:[~2019-03-19 20:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-19 19:28 LRN
2019-03-19 20:42 ` Corinna Vinschen [this message]
2019-03-20  7:18   ` LRN
2019-03-19 20:51 ` Brian Inglis

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190319204247.GQ3908@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin@cygwin.com \
    --cc=lrn1986@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).