|
|
Message-ID: <atNmp6gFoPuwfZZ7@raf.org>
Date: Sat, 17 Oct 2026 23:14:31 +1100
From: raf <musl@....org>
To: musl@...ts.openwall.com
Subject: Re: fnmatch: invalid multibyte sequence in the string is
taken as end of string ("" matches "\xff" in UTF-8 locales)
On Thu, Oct 15, 2026 at 07:49:06PM -0400, Rich Felker <dalias@...c.org> wrote:
> On Thu, Oct 15, 2026 at 07:17:16PM -0400, Rich Felker wrote:
> > On Fri, Oct 16, 2026 at 09:40:27AM +1100, raf wrote:
> > > the only one. I'd expect glibc's fnmatch to fail, because
> > > it tries to match text as characters and then as individual
> > > bytes (e.g., ?? matches éé and é).
> >
> > What is your source for that? AFAICT it does the right thing,
> > operating on characters.
>
> OK, I looked up the glibc source and it's indeed doing this horribly
> wrong. If there are any bytes that don't parse as characters in the
> pattern or string, it switches the whole match operation to a
> byte-based one.
>
> This is.... bad.
>
> Rich
When I looked at the code (it was just a quick look),
it thought it looked as though it performed the search
as characters, and then as bytes. Or maybe that's just
the behaviour. It acts like that even when all the text
is valid UTF-8. On Debian12:
> locale -a | grep en_AU
en_AU
en_AU.iso88591
en_AU.utf8
> touch é éé
> LC_ALL=en_AU.utf8 find -name '??'
./é
./éé
cheers,
raf
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.