]> granicus.if.org Git - curl/commitdiff
curl_fnmatch: only allow two asterisks for matching
authorDaniel Stenberg <daniel@haxx.se>
Fri, 18 May 2018 14:48:13 +0000 (16:48 +0200)
committerDaniel Stenberg <daniel@haxx.se>
Fri, 18 May 2018 21:33:44 +0000 (23:33 +0200)
The previous limit of 5 can still end up in situation that takes a very
long time and consumes a lot of CPU.

If there is still a rare use case for this, a user can provide their own
fnmatch callback for a version that allows a larger set of wildcards.

This commit was triggered by yet another OSS-Fuzz timeout due to this.
Bug: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=8369

Closes #2587

docs/libcurl/opts/CURLOPT_WILDCARDMATCH.3
lib/curl_fnmatch.c
tests/unit/unit1307.c

index 1ca1bedd4a3c44bc58fd80d02e5d80245e2353e7..da1fea9fb97f273894aef0d3172319d32e02add6 100644 (file)
@@ -5,7 +5,7 @@
 .\" *                            | (__| |_| |  _ <| |___
 .\" *                             \___|\___/|_| \_\_____|
 .\" *
-.\" * Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al.
+.\" * Copyright (C) 1998 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
 .\" *
 .\" * This software is licensed as described in the file COPYING, which
 .\" * you should have received as part of this distribution. The terms
@@ -41,7 +41,7 @@ A brief introduction of its syntax follows:
 .RS
 .IP "* - ASTERISK"
 \&ftp://example.com/some/path/\fB*.txt\fP (for all txt's from the root
-directory)
+directory). Only two asterisks are allowed within the same pattern string.
 .RE
 .RS
 .IP "? - QUESTION MARK"
index 0179a4f71771be7edaa2c96583838a05ec70e2f7..268fe79b376a8071e61c5da32eb0f60672a73387 100644 (file)
@@ -355,5 +355,5 @@ int Curl_fnmatch(void *ptr, const char *pattern, const char *string)
   if(!pattern || !string) {
     return CURL_FNMATCH_FAIL;
   }
-  return loop((unsigned char *)pattern, (unsigned char *)string, 5);
+  return loop((unsigned char *)pattern, (unsigned char *)string, 2);
 }
index 0d2257bf0830a7fb4f12f5ad16ac745e92398613..5f60332b8d5f26fe2fa331835a1e189bb22dd28a 100644 (file)
@@ -185,11 +185,7 @@ static const struct testcase tests[] = {
   { "\\?.txt",                  "x.txt",                  NOMATCH },
   { "\\*.txt",                  "x.txt",                  NOMATCH },
   { "\\*\\\\.txt",              "*\\.txt",                MATCH },
-  { "*\\**\\?*\\\\*",           "cc*cc?cc\\cc*cc",        MATCH },
   { "*\\**\\?*\\\\*",           "cc*cc?cccc",             NOMATCH },
-  { "*\\**\\?*\\\\*",           "cc*cc?cc\\cc*cc",        MATCH },
-  { "*\\?*\\**",                "cc?c*c",                 MATCH },
-  { "*\\?*\\**curl*",           "cc?c*curl",              MATCH },
   { "*\\?*\\**",                "cc?cc",                  NOMATCH },
   { "\\\"\\$\\&\\'\\(\\)",      "\"$&'()",                MATCH },
   { "\\*\\?\\[\\\\\\`\\|",      "*?[\\`|",                MATCH },