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 <>
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)

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

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.