From f7ecda9a356795220251764c016be3cc3c976955 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Thu, 9 May 1996 18:06:45 +0000 Subject: Updated from libc --- glob/ChangeLog | 7 +++++++ glob/fnmatch.c | 17 ++++++++++++++--- glob/glob.c | 2 +- 3 files changed, 22 insertions(+), 4 deletions(-) (limited to 'glob') diff --git a/glob/ChangeLog b/glob/ChangeLog index 5d6cc49..49e23fd 100644 --- a/glob/ChangeLog +++ b/glob/ChangeLog @@ -1,3 +1,10 @@ +Tue Apr 2 21:27:01 1996 Andreas Schwab + + * 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 * posix/glob.c (glob): In GLOB_BRACE brace expansion, fix buffer size 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; diff --git a/glob/glob.c b/glob/glob.c index eea126d..1a00af6 100644 --- a/glob/glob.c +++ b/glob/glob.c @@ -699,7 +699,7 @@ glob_pattern_p (pattern, quote) return 1; case '\\': - if (quote) + if (quote && p[1] != '\0') ++p; break; -- cgit v1.2.3