|
|
12745e |
commit 4a28f4d55a6cc33474c0792fe93b5942d81bf185
|
|
|
12745e |
Author: Andreas Schwab <schwab@suse.de>
|
|
|
12745e |
Date: Thu Feb 26 14:55:24 2015 +0100
|
|
|
12745e |
|
|
|
12745e |
Fix read past end of pattern in fnmatch (bug 18032)
|
|
|
12745e |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/posix/fnmatch_loop.c glibc-2.17-c758a686/posix/fnmatch_loop.c
|
|
|
12745e |
index c0cb2fc..72c5d8f 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/posix/fnmatch_loop.c
|
|
|
12745e |
+++ glibc-2.17-c758a686/posix/fnmatch_loop.c
|
|
|
12745e |
@@ -945,14 +945,13 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
|
|
|
12745e |
}
|
|
|
12745e |
else if (c == L('[') && *p == L('.'))
|
|
|
12745e |
{
|
|
|
12745e |
- ++p;
|
|
|
12745e |
while (1)
|
|
|
12745e |
{
|
|
|
12745e |
c = *++p;
|
|
|
12745e |
- if (c == '\0')
|
|
|
12745e |
+ if (c == L('\0'))
|
|
|
12745e |
return FNM_NOMATCH;
|
|
|
12745e |
|
|
|
12745e |
- if (*p == L('.') && p[1] == L(']'))
|
|
|
12745e |
+ if (c == L('.') && p[1] == L(']'))
|
|
|
12745e |
break;
|
|
|
12745e |
}
|
|
|
12745e |
p += 2;
|
|
|
12745e |
diff --git glibc-2.17-c758a686/posix/tst-fnmatch3.c glibc-2.17-c758a686/posix/tst-fnmatch3.c
|
|
|
12745e |
index d27a557..75bc00a 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/posix/tst-fnmatch3.c
|
|
|
12745e |
+++ glibc-2.17-c758a686/posix/tst-fnmatch3.c
|
|
|
12745e |
@@ -21,9 +21,11 @@
|
|
|
12745e |
int
|
|
|
12745e |
do_test (void)
|
|
|
12745e |
{
|
|
|
12745e |
- const char *pattern = "[[:alpha:]'[:alpha:]\0]";
|
|
|
12745e |
-
|
|
|
12745e |
- return fnmatch (pattern, "a", 0) != FNM_NOMATCH;
|
|
|
12745e |
+ if (fnmatch ("[[:alpha:]'[:alpha:]\0]", "a", 0) != FNM_NOMATCH)
|
|
|
12745e |
+ return 1;
|
|
|
12745e |
+ if (fnmatch ("[a[.\0.]]", "a", 0) != FNM_NOMATCH)
|
|
|
12745e |
+ return 1;
|
|
|
12745e |
+ return 0;
|
|
|
12745e |
}
|
|
|
12745e |
|
|
|
12745e |
#define TEST_FUNCTION do_test ()
|