Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20261119151111.GF3542221@port70.net>
Date: Thu, 19 Nov 2026 16:11:11 +0100
From: Szabolcs Nagy <nsz@...t70.net>
To: Rich Felker <dalias@...c.org>
Cc: zhaotq@....edu.cn, musl@...ts.openwall.com
Subject: Re: musl libc 1.2.5: titlecase characters violate POSIX
 lower/upper mutual exclusion

* Rich Felker <dalias@...c.org> [2026-11-19 09:06:38 -0500]:
> On Thu, Nov 19, 2026 at 01:29:21PM +0800, zhaotq@....edu.cn wrote:
> > Hello,
> > 
> > We found a POSIX character-classification defect in musl 1.2.5: some
> > characters are classified as both lower and upper. The probe selects C.UTF-8
> > before testing so that the non-ASCII wide characters are valid arguments
> > under POSIX.
> > 
> > musl implements:
> > 
> >     int iswlower(wint_t wc) { return towupper(wc) != wc; }
> >     int iswupper(wint_t wc) { return towlower(wc) != wc; }
> > 
> > Some Unicode titlecase characters, including U+01C5 and U+01C8, have case
> > mappings in both directions. Consequently musl returns nonzero from both
> > functions for those code points.
> > 
> > POSIX.1-2024 XBD 7.3.1 marks lower and upper as mutually exclusive in its
> > "Valid Character Class Combinations" table. XSH iswlower() and iswupper()
> > require nonzero results only for members of the respective class. Returning
> > nonzero from both functions for U+01C5 and U+01C8 therefore means at least
> > one classification is incorrect.
> > 
> > The probe also tests U+1F88, which musl classifies only as upper; that value
> > does not demonstrate the violation. This finding does not require all
> > titlecase characters to return zero from both functions.
> 
> This probably needs consideration for what the right fix, if anything,
> is. The normative text you're looking at is about requirements on the
> locale definition format put into the localedef utility, and may not
> even apply to an implementation-defined character classification; this
> probably requires some rules-lawyering to figure out.
> 
> Does it matter anyway though? Maybe application programmers deem these
> invariants they should be able to rely on.

current REG_ICASE handling only adds upper/lower version of a
char if it is islower/isupper, otherwise during exec only the
original char is tried. (this logic comes from tre)

so musl regex is not case-insensitive wrt these titlecase chars.

> 
> The problem is that the spec for tolower and toupper above only allows
> mappings between characters in clases lower and upper, so if titlecase
> characters are not considered lowercase and uppercase, they cannot
> have case mappings. This seems wrong; toupper and tolower should be
> defined on titlecase inputs, and the Unicode definitions make these
> mappings.
> 
> This probably calls for a request for interpretation as a possible
> error (contradictory requirements) in the standards.

yeah. but likely the api is as is for historical reasons.

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.