From 9bf0092386b6cce0998f6408d50af83e66234814 Mon Sep 17 00:00:00 2001 From: Dylan Reinhold Date: Mon, 29 Nov 2010 22:27:14 -0800 Subject: [PATCH] fnmatch - Fix edge case with trailing blackslash * Unless FNM_NOESCAPE is set a backslash in pattern followed by any other character shall match that second character in string. * Does not specify talk about the next character being null, if "st\\ring" does not match "st\\ring" why should "string\\" match "string\\". --- lib/libc/gen/fnmatch.c | 2 +- sys/libkern/fnmatch.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c index ae427cc..857e144 100644 --- a/lib/libc/gen/fnmatch.c +++ b/lib/libc/gen/fnmatch.c @@ -184,7 +184,7 @@ fnmatch1(const char *pattern, const char *string, int flags, mbstate_t patmbs, if (pclen == (size_t)-1 || pclen == (size_t)-2) return (FNM_NOMATCH); if (pclen == 0) - pc = '\\'; + pc = '\0'; pattern += pclen; } /* FALLTHROUGH */ diff --git a/sys/libkern/fnmatch.c b/sys/libkern/fnmatch.c index bb99e58..ade3254 100644 --- a/sys/libkern/fnmatch.c +++ b/sys/libkern/fnmatch.c @@ -144,7 +144,7 @@ _kfnmatch(const char *pattern, const char *string, int flags, int nesting) case '\\': if (!(flags & FNM_NOESCAPE)) { if ((c = *pattern++) == EOS) { - c = '\\'; + c = '\0'; --pattern; } } -- 1.6.4