summaryrefslogtreecommitdiff
path: root/libc
diff options
context:
space:
mode:
authorWaldemar Brodkorb <wbx@uclibc-ng.org>2016-11-25 20:55:22 +0100
committerWaldemar Brodkorb <wbx@uclibc-ng.org>2016-11-27 16:35:31 +0100
commit031d4eef8d055fbdae8d2fe4f59047e83601a15d (patch)
tree5919f812bbe5183c71ee1504251c209e69f1d335 /libc
parent8dd85e041bdccf630c90e12ea044f55d28da9396 (diff)
Fix handling of unterminated [ expression in fnmatch.
Originally fixed in GNU libc by: commit 794c3ad3a405697e2663b00f616e319383b9bb7d Author: Ulrich Drepper <drepper@gmail.com> Date: Fri Jan 14 08:06:22 2011 -0500 Reported-by: Denys Vlasenko <vda.linux@googlemail.com> via busybox mailinglist.
Diffstat (limited to 'libc')
-rw-r--r--libc/misc/fnmatch/fnmatch_loop.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/libc/misc/fnmatch/fnmatch_loop.c b/libc/misc/fnmatch/fnmatch_loop.c
index 6d037f8f9..a09cfbb11 100644
--- a/libc/misc/fnmatch/fnmatch_loop.c
+++ b/libc/misc/fnmatch/fnmatch_loop.c
@@ -204,6 +204,8 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
case L('['):
{
/* Nonzero if the sense of the character class is inverted. */
+ CHAR *p_init = p;
+ CHAR *n_init = n;
register int not;
CHAR cold;
UCHAR fn;
@@ -409,8 +411,13 @@ FCT (const CHAR *pattern, const CHAR *string, const CHAR *string_end,
}
#endif
else 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;
+ }
else
{
int is_range = 0;