Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 23 Apr 2010 18:01:20 +0000 (UTC)
From:      Jilles Tjoelker <jilles@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org
Subject:   svn commit: r207129 - in stable/8: lib/libc/gen tools/regression/lib/libc/gen
Message-ID:  <201004231801.o3NI1K3e073105@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jilles
Date: Fri Apr 23 18:01:19 2010
New Revision: 207129
URL: http://svn.freebsd.org/changeset/base/207129

Log:
  MFC r206711: fnmatch: Fix bad FNM_PERIOD disabling
  if an asterisk has been seen.
  
  Example: fnmatch("a*b/*", "abbb/.x", FNM_PATHNAME | FNM_PERIOD)
  
  PR:		116074

Modified:
  stable/8/lib/libc/gen/fnmatch.c
  stable/8/tools/regression/lib/libc/gen/test-fnmatch.c
Directory Properties:
  stable/8/lib/libc/   (props changed)
  stable/8/lib/libc/stdtime/   (props changed)
  stable/8/tools/regression/lib/libc/   (props changed)

Modified: stable/8/lib/libc/gen/fnmatch.c
==============================================================================
--- stable/8/lib/libc/gen/fnmatch.c	Fri Apr 23 17:52:36 2010	(r207128)
+++ stable/8/lib/libc/gen/fnmatch.c	Fri Apr 23 18:01:19 2010	(r207129)
@@ -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,
 
 			/* 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);

Modified: stable/8/tools/regression/lib/libc/gen/test-fnmatch.c
==============================================================================
--- stable/8/tools/regression/lib/libc/gen/test-fnmatch.c	Fri Apr 23 17:52:36 2010	(r207128)
+++ stable/8/tools/regression/lib/libc/gen/test-fnmatch.c	Fri Apr 23 18:01:19 2010	(r207129)
@@ -174,6 +174,7 @@ struct testcase {
 	"*a", ".a/b", FNM_PATHNAME | FNM_LEADING_DIR, 0,
 	"*", ".a/b", FNM_PATHNAME | FNM_PERIOD | FNM_LEADING_DIR, FNM_NOMATCH,
 	"*a", ".a/b", FNM_PATHNAME | FNM_PERIOD | FNM_LEADING_DIR, FNM_NOMATCH,
+	"a*b/*", "abbb/.x", FNM_PATHNAME | FNM_PERIOD, FNM_NOMATCH,
 };
 
 static const char *



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201004231801.o3NI1K3e073105>