diff options
author | pfg <pfg@FreeBSD.org> | 2017-08-15 00:54:16 +0000 |
---|---|---|
committer | pfg <pfg@FreeBSD.org> | 2017-08-15 00:54:16 +0000 |
commit | b5bf4d72d917538b415d917959f41c8dd7478798 (patch) | |
tree | 27c310cefcee2615a2bf4f669414b7421cc72ba5 | |
parent | 03a37e0a48ec05481519ea016980e20a34455673 (diff) | |
download | FreeBSD-src-b5bf4d72d917538b415d917959f41c8dd7478798.zip FreeBSD-src-b5bf4d72d917538b415d917959f41c8dd7478798.tar.gz |
MFC r322368, r322371:
fnmatch(3): improve POSIX conformance.
In a recent interpretation[1], "\\" shall return a non-zero value
(indicating either no match or an error).
The fix involves a change over r254091 and now the behavior matches the
Sun/IBM/HP closed source implementations and also likely musl libc.
Submitted by: Joerg Schilling <joerg at schily.net>
[1] http://austingroupbugs.net/view.php?id=806
-rw-r--r-- | lib/libc/gen/fnmatch.c | 3 | ||||
-rw-r--r-- | lib/libc/tests/gen/fnmatch_testcases.h | 2 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c index 65efe20..d18e345 100644 --- a/lib/libc/gen/fnmatch.c +++ b/lib/libc/gen/fnmatch.c @@ -184,7 +184,8 @@ fnmatch1(const char *pattern, const char *string, const char *stringstart, if (!(flags & FNM_NOESCAPE)) { pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs); - if (pclen == (size_t)-1 || pclen == (size_t)-2) + if (pclen == 0 || pclen == (size_t)-1 || + pclen == (size_t)-2) return (FNM_NOMATCH); pattern += pclen; } diff --git a/lib/libc/tests/gen/fnmatch_testcases.h b/lib/libc/tests/gen/fnmatch_testcases.h index 537011f..996e13c 100644 --- a/lib/libc/tests/gen/fnmatch_testcases.h +++ b/lib/libc/tests/gen/fnmatch_testcases.h @@ -131,7 +131,7 @@ struct testcase { { "\\(", "\\(", 0, FNM_NOMATCH }, { "\\a", "\\a", 0, FNM_NOMATCH }, { "\\", "\\", 0, FNM_NOMATCH }, - { "\\", "", 0, 0 }, + { "\\", "", 0, FNM_NOMATCH }, { "\\*", "\\*", FNM_NOESCAPE, 0 }, { "\\?", "\\?", FNM_NOESCAPE, 0 }, { "\\", "\\", FNM_NOESCAPE, 0 }, |