Updated from libc
authorRoland McGrath <roland@redhat.com>
Thu, 9 May 1996 18:06:45 +0000 (18:06 +0000)
committerRoland McGrath <roland@redhat.com>
Thu, 9 May 1996 18:06:45 +0000 (18:06 +0000)
glob/ChangeLog
glob/fnmatch.c
glob/glob.c

index 5d6cc4979720f0a4c73af089814271896c85808b..49e23fd6e6a76aeb57478fc2b72884d189fd003a 100644 (file)
@@ -1,3 +1,10 @@
+Tue Apr  2 21:27:01 1996  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>
+
+       * posix/glob.c (glob_pattern_p): Avoid scanning past eos if
+       the pattern ends with a backslash and quoting is enabled.
+       * posix/fnmatch.c (fnmatch): Likewise; return FNM_NOMATCH for such
+       patterns.
+
 Thu Mar 14 06:01:07 1996  Roland McGrath  <roland@charlie-brown.gnu.ai.mit.edu>
 
        * posix/glob.c (glob): In GLOB_BRACE brace expansion, fix buffer size
index 1ddea809616e2998d98147106b15b4d3d05f1293..08c1c9448e50aea77f9afd7a51d30ed8262eba93 100644 (file)
@@ -78,6 +78,9 @@ fnmatch (pattern, string, flags)
          if (!(flags & FNM_NOESCAPE))
            {
              c = *p++;
+             if (c == '\0')
+               /* Trailing \ loses.  */
+               return FNM_NOMATCH;
              c = FOLD (c);
            }
          if (FOLD (*n) != c)
@@ -129,7 +132,11 @@ fnmatch (pattern, string, flags)
                register char cstart = c, cend = c;
 
                if (!(flags & FNM_NOESCAPE) && c == '\\')
-                 cstart = cend = *p++;
+                 {
+                   if (*p == '\0')
+                     return FNM_NOMATCH;
+                   cstart = cend = *p++;
+                 }
 
                cstart = cend = FOLD (cstart);
 
@@ -176,8 +183,12 @@ fnmatch (pattern, string, flags)
 
                c = *p++;
                if (!(flags & FNM_NOESCAPE) && c == '\\')
-                 /* XXX 1003.2d11 is unclear if this is right.  */
-                 ++p;
+                 {
+                   if (*p == '\0')
+                     return FNM_NOMATCH;
+                   /* XXX 1003.2d11 is unclear if this is right.  */
+                   ++p;
+                 }
              }
            if (not)
              return FNM_NOMATCH;
index eea126d8004093f544c1cbb27694766dbb28a6c8..1a00af6f3fca5b1bfabe34fe4593f003d5f8e6a0 100644 (file)
@@ -699,7 +699,7 @@ glob_pattern_p (pattern, quote)
        return 1;
 
       case '\\':
-       if (quote)
+       if (quote && p[1] != '\0')
          ++p;
        break;