diff options
author | Andreas Schwab <schwab@linux-m68k.org> | 2022-01-18 16:31:39 +0100 |
---|---|---|
committer | Andreas Schwab <schwab@linux-m68k.org> | 2022-01-24 17:13:33 +0100 |
commit | 8442f0d966da5a9333e961af9e98b41aabdd9f1b (patch) | |
tree | a2d119ef37abe3e91b5e53822e52e289419d4711 /posix/fnmatch_loop.c | |
parent | 84d2d0fe20bdf94feed82b21b4d7d136db471f03 (diff) | |
download | glibc-8442f0d966da5a9333e961af9e98b41aabdd9f1b.tar glibc-8442f0d966da5a9333e961af9e98b41aabdd9f1b.tar.gz glibc-8442f0d966da5a9333e961af9e98b41aabdd9f1b.tar.bz2 glibc-8442f0d966da5a9333e961af9e98b41aabdd9f1b.zip |
Fix handling of unterminated bracket expressions in fnmatch (bug 28792)
When fnmatch processes a bracket expression, and eventually finds it to be
unterminated, it should rescan it, treating the starting bracket as a
normal character. That didn't happen when a matching character was found
while scanning the bracket expression.
Diffstat (limited to 'posix/fnmatch_loop.c')
-rw-r--r-- | posix/fnmatch_loop.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c index cab4e1b684..9445ed9c58 100644 --- a/posix/fnmatch_loop.c +++ b/posix/fnmatch_loop.c @@ -823,8 +823,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end, while ((c = *p++) != L_(']')) { if (c == L_('\0')) - /* [... (unterminated) loses. */ - return FNM_NOMATCH; + { + /* [ unterminated, treat as normal character. */ + p = p_init; + n = n_init; + c = L_('['); + goto normal_match; + } if (!(flags & FNM_NOESCAPE) && c == L_('\\')) { |