Message ID | CALoOobOKfc9XKEQMbv9uwXTEaer-t=d1FwfOMv61YAOBUBV3_A@mail.gmail.com |
---|---|
State | New |
Headers | show |
On 02/28/2015 06:25 AM, Paul Pluzhnikov wrote: > else if ((*p == L('?') || *p == L('*') || *p == L('+') || *p == L('@') > || *p == L('!')) && p[1] == L('(')) > - p = END (p + 1); > + { > + p = END (p + 1); > + if (*p == L('\0')) > + /* This is an invalid pattern. */ > + return pattern; > + } Okay to commit if you have checked that the test case actually tests the bug. Thanks.
diff --git a/posix/fnmatch_loop.c b/posix/fnmatch_loop.c index 72c5d8f..f46c9df 100644 --- a/posix/fnmatch_loop.c +++ b/posix/fnmatch_loop.c @@ -1036,7 +1036,12 @@ END (const CHAR *pattern) } else if ((*p == L('?') || *p == L('*') || *p == L('+') || *p == L('@') || *p == L('!')) && p[1] == L('(')) - p = END (p + 1); + { + p = END (p + 1); + if (*p == L('\0')) + /* This is an invalid pattern. */ + return pattern; + } else if (*p == L(')')) break; diff --git a/posix/tst-fnmatch3.c b/posix/tst-fnmatch3.c index 75bc00a..7822a35 100644 --- a/posix/tst-fnmatch3.c +++ b/posix/tst-fnmatch3.c @@ -25,6 +25,8 @@ do_test (void) return 1; if (fnmatch ("[a[.\0.]]", "a", 0) != FNM_NOMATCH) return 1; + if (fnmatch (" ", "**(!()", 0) != FNM_NOMATCH) + return 1; return 0; }