From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 33204 invoked by alias); 19 Mar 2019 20:42:53 -0000 Mailing-List: contact cygwin-help@cygwin.com; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: cygwin-owner@cygwin.com Mail-Followup-To: cygwin@cygwin.com Received: (qmail 33193 invoked by uid 89); 19 Mar 2019 20:42:52 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-101.8 required=5.0 tests=AWL,BAYES_00,GOOD_FROM_CORINNA_CYGWIN,RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 spammy=lz, Lz, desktop, uploaded X-HELO: mout.kundenserver.de Received: from mout.kundenserver.de (HELO mout.kundenserver.de) (212.227.126.130) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 19 Mar 2019 20:42:51 +0000 Received: from calimero.vinschen.de ([24.134.7.25]) by mrelayeu.kundenserver.de (mreue010 [212.227.15.167]) with ESMTPSA (Nemesis) id 1MbAtM-1gZUn21LgG-00bbCc; Tue, 19 Mar 2019 21:42:48 +0100 Received: by calimero.vinschen.de (Postfix, from userid 500) id 8202AA80970; Tue, 19 Mar 2019 21:42:47 +0100 (CET) Date: Tue, 19 Mar 2019 20:42:00 -0000 From: Corinna Vinschen To: LRN Cc: cygwin@cygwin.com Subject: Re: wcsxfrm() with empty locale crashes the runtime Message-ID: <20190319204247.GQ3908@calimero.vinschen.de> Reply-To: cygwin@cygwin.com Mail-Followup-To: LRN , cygwin@cygwin.com References: <02f956fa-e872-87ba-9ab0-f10afc494a02@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="WlEyl6ow+jlIgNUh" Content-Disposition: inline In-Reply-To: <02f956fa-e872-87ba-9ab0-f10afc494a02@gmail.com> User-Agent: Mutt/1.11.3 (2019-02-01) X-SW-Source: 2019-03/txt/msg00493.txt.bz2 --WlEyl6ow+jlIgNUh Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable Content-length: 1200 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. >=20 > Tested with Cygwin-3.0.4. > #include > #include > #include >=20 > int > main () > { > wchar_t w[2] =3D { L'z', L'\0' }; > setlocale (LC_ALL, ""); > int l =3D 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=3Dnewlib-cygwin.git;a=3Dcommitd= iff;h=3Dc0d7d3e1a2fa (**) https://docs.microsoft.com/en-us/windows/desktop/api/winnls/nf-winnls-= lcmapstringex --=20 Corinna Vinschen Cygwin Maintainer --WlEyl6ow+jlIgNUh Content-Type: application/pgp-signature; name="signature.asc" Content-length: 833 -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEoVYPmneWZnwT6kwF9TYGna5ET6AFAlyRVEcACgkQ9TYGna5E T6Dnbg//ZCkpsoCsNF+uGgKI818r8se951PpjZWlB0nqpFhve4QFXR76uGo4Rww/ BJ0lks6VNGgKbjhypqKq0eEBmEmMNY/csDWRIJ0VvcM5s6FiZC5lu1N927OE3Bde WZGGocSPVUZVch7Ka80g86+74ZkJgn5ZQcpHN7cIoOnB75gAuOy6pvwm2ypimn/N 8QqteNqxA0IJkNXoqgHZ/EAyPxdGMAONilma0Ph28+k/yxPsdy5N95a5dQBVV94W NsltEFnP6/KD47UwaDrcakXAB8Bjf97ISkCs78kYc029ASLMADXgYs11qUap7WSD ezP2pmybe5IAaC6F+ughJqdk7IwOf71LDHsP108u1egAWswdIs1TWk4JGG8Qf0ZT Y+ZZ2s3VfXIDaT2h1LvQotkELkNClF3XuqSco9Ul1KZkWQUeLFo1Dh4eW7xV+mdo rlXxqzYom3c9ETrrgfHD6SOKQ+6Kz8KUuKz2dd5A80ZmYCyP8HvKKIjj3emBTfe3 5w3PbDO8wENd/HGa3cD/cnGR1EljPrP5PEk4kTzwaPfWMEOz9dPgUzkvAABnnaiF bf1T6I5xzhpN1DgKDOjSUO+/WJe1DQi9P9C1xkqe8qqqgvHjFDHM8MJmIT+GlyEN 5EwAqJy1UkOueG6EuQnqjfIpq8Pmjlz6MPL/VSBLZE8bEC0Xl1M= =3ZGX -----END PGP SIGNATURE----- --WlEyl6ow+jlIgNUh--