mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Tavian Barnes <tavianator@tavianator.com>
To: musl@lists.openwall.com
Subject: [musl] fnmatch trailing backslash
Date: Fri, 25 Feb 2022 10:44:52 -0500	[thread overview]
Message-ID: <CABg4E-=fgir2Qmy6o5zvXKOMsKkTSNBKQSQeH+dBPCucc5X-vQ@mail.gmail.com> (raw)

I noticed that fnmatch() behaviour with a trailing unescaped backslash
differs between glibc and musl:

$ cat foo.c
#include <assert.h>
#include <fnmatch.h>

int main(void) {
        assert(fnmatch("\\", "\\", 0) != 0);
        return 0;
}
$ gcc foo.c -o foo && ./foo
$ musl-gcc foo.c -o foo && ./foo
Assertion failed: fnmatch("\\", "\\", 0) != 0 (foo.c: main: 5)

In https://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html,
POSIX says:

> If pattern ends with an unescaped <backslash>, fnmatch() shall return a non-zero value (indicating either no match or an error).

And interestingly, it was a defect report from Rich that led to that
wording: https://www.austingroupbugs.net/view.php?id=806

-- 
Tavian Barnes

                 reply	other threads:[~2022-02-25 15:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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='CABg4E-=fgir2Qmy6o5zvXKOMsKkTSNBKQSQeH+dBPCucc5X-vQ@mail.gmail.com' \
    --to=tavianator@tavianator.com \
    --cc=musl@lists.openwall.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.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

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 NNTP newsgroup(s).