summaryrefslogtreecommitdiffstats
path: root/lib/libc
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2010-04-16 22:29:24 +0000
committerjilles <jilles@FreeBSD.org>2010-04-16 22:29:24 +0000
commitbb1d9873c9ec91bbb05a745714c9ef9a0ff0348d (patch)
treea10321d55ecaf439cae54c164b76572c3600a5b8 /lib/libc
parentdd4fae15ab98e71f83cde37dbcb35b8951ddaff6 (diff)
downloadFreeBSD-src-bb1d9873c9ec91bbb05a745714c9ef9a0ff0348d.zip
FreeBSD-src-bb1d9873c9ec91bbb05a745714c9ef9a0ff0348d.tar.gz
fnmatch: Fix bad FNM_PERIOD disabling if an asterisk has been seen.
Example: fnmatch("a*b/*", "abbb/.x", FNM_PATHNAME | FNM_PERIOD) PR: 116074 MFC after: 1 week
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/gen/fnmatch.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c
index e697bdc..3acbc3b 100644
--- a/lib/libc/gen/fnmatch.c
+++ b/lib/libc/gen/fnmatch.c
@@ -67,7 +67,8 @@ __FBSDID("$FreeBSD$");
#define RANGE_ERROR (-1)
static int rangematch(const char *, wchar_t, int, char **, mbstate_t *);
-static int fnmatch1(const char *, const char *, int, mbstate_t, mbstate_t);
+static int fnmatch1(const char *, const char *, const char *, int, mbstate_t,
+ mbstate_t);
int
fnmatch(pattern, string, flags)
@@ -76,22 +77,21 @@ fnmatch(pattern, string, flags)
{
static const mbstate_t initial;
- return (fnmatch1(pattern, string, flags, initial, initial));
+ return (fnmatch1(pattern, string, string, flags, initial, initial));
}
static int
-fnmatch1(pattern, string, flags, patmbs, strmbs)
- const char *pattern, *string;
+fnmatch1(pattern, string, stringstart, flags, patmbs, strmbs)
+ const char *pattern, *string, *stringstart;
int flags;
mbstate_t patmbs, strmbs;
{
- const char *stringstart;
char *newp;
char c;
wchar_t pc, sc;
size_t pclen, sclen;
- for (stringstart = string;;) {
+ for (;;) {
pclen = mbrtowc(&pc, pattern, MB_LEN_MAX, &patmbs);
if (pclen == (size_t)-1 || pclen == (size_t)-2)
return (FNM_NOMATCH);
@@ -145,8 +145,8 @@ fnmatch1(pattern, string, flags, patmbs, strmbs)
/* General case, use recursion. */
while (sc != EOS) {
- if (!fnmatch1(pattern, string,
- flags & ~FNM_PERIOD, patmbs, strmbs))
+ if (!fnmatch1(pattern, string, stringstart,
+ flags, patmbs, strmbs))
return (0);
sclen = mbrtowc(&sc, string, MB_LEN_MAX,
&strmbs);
OpenPOWER on IntegriCloud