diff options
Diffstat (limited to 'httpd/patterns.c')
-rw-r--r-- | httpd/patterns.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/httpd/patterns.c b/httpd/patterns.c index 1dbea15..62c8078 100644 --- a/httpd/patterns.c +++ b/httpd/patterns.c @@ -48,6 +48,7 @@ struct match_state { int matchdepth; /* control for recursive depth (to avoid C * stack overflow) */ + int repetitioncounter; /* control the repetition items */ int maxcaptures; /* configured capture limit */ const char *src_init; /* init of source string */ const char *src_end; /* end ('\0') of source string */ @@ -425,6 +426,11 @@ match(struct match_state *ms, const char *s, const char *p) /* does not match at least once? */ if (!singlematch(ms, s, p, ep)) { + if (ms->repetitioncounter-- == 0) { + match_error(ms, "max repetition items"); + s = NULL; /* fail */ + } else + /* accept empty? */ if (*ep == '*' || *ep == '?' || *ep == '-') { p = ep + 1; @@ -615,6 +621,7 @@ str_find_aux(struct match_state *ms, const char *pattern, const char *string, } ms->maxcaptures = (nsm > MAXCAPTURES ? MAXCAPTURES : nsm) - 1; ms->matchdepth = MAXCCALLS; + ms->repetitioncounter = MAXREPETITION; ms->src_init = s; ms->src_end = s + ls; ms->p_end = p + lp; |