|
|
12745e |
commit b3a9f56ba59c3d8eadd3135a1c25c37a63151450
|
|
|
12745e |
Author: Andreas Schwab <schwab@suse.de>
|
|
|
12745e |
Date: Wed Jun 18 11:58:45 2014 +0200
|
|
|
12745e |
|
|
|
12745e |
Don't read past end of pattern in fnmatch (BZ #17062)
|
|
|
12745e |
|
|
|
12745e |
diff --git glibc-2.17-c758a686/posix/fnmatch_loop.c glibc-2.17-c758a686/posix/fnmatch_loop.c
|
|
|
12745e |
index f79d051..544769b 100644
|
|
|
12745e |
--- glibc-2.17-c758a686/posix/fnmatch_loop.c
|
|
|
12745e |
+++ glibc-2.17-c758a686/posix/fnmatch_loop.c
|
|
|
12745e |
@@ -899,11 +899,8 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
|
|
|
12745e |
|
|
|
12745e |
matched:
|
|
|
12745e |
/* Skip the rest of the [...] that already matched. */
|
|
|
12745e |
- do
|
|
|
12745e |
+ while ((c = *p++) != L (']'))
|
|
|
12745e |
{
|
|
|
12745e |
- ignore_next:
|
|
|
12745e |
- c = *p++;
|
|
|
12745e |
-
|
|
|
12745e |
if (c == L('\0'))
|
|
|
12745e |
/* [... (unterminated) loses. */
|
|
|
12745e |
return FNM_NOMATCH;
|
|
|
12745e |
@@ -931,12 +928,11 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
|
|
|
12745e |
|
|
|
12745e |
if (c < L('a') || c >= L('z'))
|
|
|
12745e |
{
|
|
|
12745e |
- p = startp;
|
|
|
12745e |
- goto ignore_next;
|
|
|
12745e |
+ p = startp - 2;
|
|
|
12745e |
+ break;
|
|
|
12745e |
}
|
|
|
12745e |
}
|
|
|
12745e |
p += 2;
|
|
|
12745e |
- c = *p++;
|
|
|
12745e |
}
|
|
|
12745e |
else if (c == L('[') && *p == L('='))
|
|
|
12745e |
{
|
|
|
12745e |
@@ -947,7 +943,6 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
|
|
|
12745e |
if (c != L('=') || p[1] != L(']'))
|
|
|
12745e |
return FNM_NOMATCH;
|
|
|
12745e |
p += 2;
|
|
|
12745e |
- c = *p++;
|
|
|
12745e |
}
|
|
|
12745e |
else if (c == L('[') && *p == L('.'))
|
|
|
12745e |
{
|
|
|
12745e |
@@ -962,10 +957,8 @@ FCT (pattern, string, string_end, no_leading_period, flags, ends, alloca_used)
|
|
|
12745e |
break;
|
|
|
12745e |
}
|
|
|
12745e |
p += 2;
|
|
|
12745e |
- c = *p++;
|
|
|
12745e |
}
|
|
|
12745e |
}
|
|
|
12745e |
- while (c != L(']'));
|
|
|
12745e |
if (not)
|
|
|
12745e |
return FNM_NOMATCH;
|
|
|
12745e |
}
|
|
|
12745e |
diff --git glibc-2.17-c758a686/posix/tst-fnmatch3.c glibc-2.17-c758a686/posix/tst-fnmatch3.c
|
|
|
12745e |
new file mode 100644
|
|
|
12745e |
index 0000000..2a83c1b
|
|
|
12745e |
--- /dev/null
|
|
|
12745e |
+++ glibc-2.17-c758a686/posix/tst-fnmatch3.c
|
|
|
12745e |
@@ -0,0 +1,30 @@
|
|
|
12745e |
+/* Test for fnmatch not reading past the end of the pattern.
|
|
|
12745e |
+ Copyright (C) 2014 Free Software Foundation, Inc.
|
|
|
12745e |
+ This file is part of the GNU C Library.
|
|
|
12745e |
+
|
|
|
12745e |
+ The GNU C Library is free software; you can redistribute it and/or
|
|
|
12745e |
+ modify it under the terms of the GNU Lesser General Public
|
|
|
12745e |
+ License as published by the Free Software Foundation; either
|
|
|
12745e |
+ version 2.1 of the License, or (at your option) any later version.
|
|
|
12745e |
+
|
|
|
12745e |
+ The GNU C Library is distributed in the hope that it will be useful,
|
|
|
12745e |
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
12745e |
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
12745e |
+ Lesser General Public License for more details.
|
|
|
12745e |
+
|
|
|
12745e |
+ You should have received a copy of the GNU Lesser General Public
|
|
|
12745e |
+ License along with the GNU C Library; if not, see
|
|
|
12745e |
+ <http://www.gnu.org/licenses/>. */
|
|
|
12745e |
+
|
|
|
12745e |
+#include <fnmatch.h>
|
|
|
12745e |
+
|
|
|
12745e |
+int
|
|
|
12745e |
+do_test (void)
|
|
|
12745e |
+{
|
|
|
12745e |
+ const char *pattern = "[[:alpha:]'[:alpha:]\0]";
|
|
|
12745e |
+
|
|
|
12745e |
+ return fnmatch (pattern, "a", 0) != FNM_NOMATCH;
|
|
|
12745e |
+}
|
|
|
12745e |
+
|
|
|
12745e |
+#define TEST_FUNCTION do_test ()
|
|
|
12745e |
+#include "../test-skeleton.c"
|
|
|
12745e |
--- glibc-2.17-c758a686/posix/Makefile 2015-05-15 16:00:01.000000000 -0400
|
|
|
12745e |
+++ glibc-2.17-c758a686/posix/Makefile 2015-05-29 18:34:07.507240952 -0400
|
|
|
12745e |
@@ -87,7 +87,7 @@
|
|
|
12745e |
tst-getaddrinfo3 tst-fnmatch2 tst-cpucount tst-cpuset \
|
|
|
12745e |
bug-getopt1 bug-getopt2 bug-getopt3 bug-getopt4 \
|
|
|
12745e |
bug-getopt5 tst-getopt_long1 bug-regex34 \
|
|
|
12745e |
- tst-pathconf
|
|
|
12745e |
+ tst-pathconf tst-fnmatch3
|
|
|
12745e |
xtests := bug-ga2
|
|
|
12745e |
ifeq (yes,$(build-shared))
|
|
|
12745e |
test-srcs := globtest
|