Message ID | c6f2d44622f10cfee3c48a7d13b3de9607d1061d.1679328580.git.phillip.wood@dunelm.org.uk (mailing list archive) |
---|---|
State | Accepted |
Commit | 81b26f8f2891f1a63d5dbf7c2d4209b8325062b6 |
Headers | show |
Series | wildmatch: fix exponential behavior | expand |
diff --git a/wildmatch.c b/wildmatch.c index 06861bd8bc..694d2f8e40 100644 --- a/wildmatch.c +++ b/wildmatch.c @@ -83,12 +83,12 @@ static int dowild(const uchar *p, const uchar *text, unsigned int flags) continue; case '*': if (*++p == '*') { - const uchar *prev_p = p - 2; + const uchar *prev_p = p; while (*++p == '*') {} if (!(flags & WM_PATHNAME)) /* without WM_PATHNAME, '*' == '**' */ match_slash = 1; - else if ((prev_p < pattern || *prev_p == '/') && + else if ((prev_p - pattern < 2 || *(prev_p - 2) == '/') && (*p == '\0' || *p == '/' || (p[0] == '\\' && p[1] == '/'))) { /*