Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Date: Fri, 25 Feb 2022 10:44:52 -0500
From: Tavian Barnes <tavianator@...ianator.com>
To: musl@...ts.openwall.com
Subject: fnmatch trailing backslash

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

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.