summaryrefslogtreecommitdiff
path: root/glob/fnmatch.c
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>1996-05-09 18:06:45 +0000
committerRoland McGrath <roland@redhat.com>1996-05-09 18:06:45 +0000
commitf7ecda9a356795220251764c016be3cc3c976955 (patch)
tree67bb4e1764e14c9793265b11709839f3f349f631 /glob/fnmatch.c
parente99a3aca7ec9796973a7e4d93676c5c13483a948 (diff)
downloadgunmake-f7ecda9a356795220251764c016be3cc3c976955.tar.gz
Updated from libc
Diffstat (limited to 'glob/fnmatch.c')
-rw-r--r--glob/fnmatch.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/glob/fnmatch.c b/glob/fnmatch.c
index 1ddea80..08c1c94 100644
--- a/glob/fnmatch.c
+++ b/glob/fnmatch.c
@@ -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;