New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fnmatch: insist on escaped bracket to match #2614

Closed
wants to merge 1 commit into
base: master
from
Jump to file or symbol
Failed to load files and symbols.
+15 −6
Diff settings

Always

Just for now

Copy path View file
@@ -334,9 +334,9 @@ static int loop(const unsigned char *pattern, const unsigned char *string,
s++;
break;
}
/* Syntax error in set; mismatch! */
return CURL_FNMATCH_NOMATCH;
/* Syntax error in set: this must be taken as a regular character. */
/* FALLTHROUGH */
default:
if(*p++ != *s++)
return CURL_FNMATCH_NOMATCH;
Copy path View file
@@ -34,9 +34,17 @@ struct testcase {
static const struct testcase tests[] = {
/* brackets syntax */
{"*[*[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[\001\177[[[[[[[[[[[[[[[[[[[[[",
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[["
"[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[",
NOMATCH},
{ "\\[", "[", MATCH },
{ "[", "[", MATCH },
{ "[]", "[]", MATCH },
{ "[", "[", NOMATCH },
{ "[]", "[]", NOMATCH },
{ "[][]", "[", MATCH },
{ "[][]", "]", MATCH },
{ "[[]", "[", MATCH },
@@ -230,8 +238,9 @@ UNITTEST_START
for(i = 0; i < testnum; i++) {
rc = Curl_fnmatch(NULL, tests[i].pattern, tests[i].string);
if(rc != tests[i].result) {
printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)\n",
tests[i].pattern, tests[i].string, tests[i].result, rc);
printf("Curl_fnmatch(\"%s\", \"%s\") should return %d (returns %d)"
" [%d]\n",
tests[i].pattern, tests[i].string, tests[i].result, rc, i);
fail("pattern mismatch");
}
}
ProTip! Use n and p to navigate between commits in a pull request.