aboutsummaryrefslogtreecommitdiff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/fnmatch.c17
-rw-r--r--posix/glob.c2
2 files changed, 15 insertions, 4 deletions
diff --git a/posix/fnmatch.c b/posix/fnmatch.c
index 1ddea80..08c1c94 100644
--- a/posix/fnmatch.c
+++ b/posix/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;
diff --git a/posix/glob.c b/posix/glob.c
index eea126d..1a00af6 100644
--- a/posix/glob.c
+++ b/posix/glob.c
@@ -699,7 +699,7 @@ glob_pattern_p (pattern, quote)
return 1;
case '\\':
- if (quote)
+ if (quote && p[1] != '\0')
++p;
break;