match: Optimize pattern matching even more
The adjacent question marks and asterisks can be simplified to single wildcard so there is no need to excersise all the recursive pattern matching. These inputs were generated by oss-fuzz and probably caused also the previously reported timeouts. Signed-off-by: Jakub Jelen <jjelen@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Этот коммит содержится в:
родитель
44665f33a4
Коммит
d171a6e444
@ -63,9 +63,11 @@ static int match_pattern(const char *s, const char *pattern, size_t limit)
|
||||
return (*s == '\0');
|
||||
}
|
||||
|
||||
while (*pattern == '*') {
|
||||
/* Skip all the asterisks. */
|
||||
had_asterisk = true;
|
||||
/* Skip all the asterisks and adjacent question marks */
|
||||
while (*pattern == '*' || (had_asterisk && *pattern == '?')) {
|
||||
if (*pattern == '*') {
|
||||
had_asterisk = true;
|
||||
}
|
||||
pattern++;
|
||||
}
|
||||
|
||||
|
Загрузка…
Ссылка в новой задаче
Block a user