ce426f
commit 4a28f4d55a6cc33474c0792fe93b5942d81bf185
ce426f
Author: Andreas Schwab <schwab@suse.de>
ce426f
Date:   Thu Feb 26 14:55:24 2015 +0100
ce426f
ce426f
    Fix read past end of pattern in fnmatch (bug 18032)
ce426f
ce426f
diff --git glibc-2.17-c758a686/posix/fnmatch_loop.c glibc-2.17-c758a686/posix/fnmatch_loop.c
ce426f
index c0cb2fc..72c5d8f 100644
ce426f
--- glibc-2.17-c758a686/posix/fnmatch_loop.c
ce426f
+++ glibc-2.17-c758a686/posix/fnmatch_loop.c
ce426f
@@ -945,14 +945,13 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
ce426f
 		  }
ce426f
 		else if (c == L('[') && *p == L('.'))
ce426f
 		  {
ce426f
-		    ++p;
ce426f
 		    while (1)
ce426f
 		      {
ce426f
 			c = *++p;
ce426f
-			if (c == '\0')
ce426f
+			if (c == L('\0'))
ce426f
 			  return FNM_NOMATCH;
ce426f
 
ce426f
-			if (*p == L('.') && p[1] == L(']'))
ce426f
+			if (c == L('.') && p[1] == L(']'))
ce426f
 			  break;
ce426f
 		      }
ce426f
 		    p += 2;
ce426f
diff --git glibc-2.17-c758a686/posix/tst-fnmatch3.c glibc-2.17-c758a686/posix/tst-fnmatch3.c
ce426f
index d27a557..75bc00a 100644
ce426f
--- glibc-2.17-c758a686/posix/tst-fnmatch3.c
ce426f
+++ glibc-2.17-c758a686/posix/tst-fnmatch3.c
ce426f
@@ -21,9 +21,11 @@
ce426f
 int
ce426f
 do_test (void)
ce426f
 {
ce426f
-  const char *pattern = "[[:alpha:]'[:alpha:]\0]";
ce426f
-
ce426f
-  return fnmatch (pattern, "a", 0) != FNM_NOMATCH;
ce426f
+  if (fnmatch ("[[:alpha:]'[:alpha:]\0]", "a", 0) != FNM_NOMATCH)
ce426f
+    return 1;
ce426f
+  if (fnmatch ("[a[.\0.]]", "a", 0) != FNM_NOMATCH)
ce426f
+    return 1;
ce426f
+  return 0;
ce426f
 }
ce426f
 
ce426f
 #define TEST_FUNCTION do_test ()