From cb9aff69125a32fd4327cce7079eb18273356d92 Mon Sep 17 00:00:00 2001 From: Sébastien Marie Date: Tue, 23 Jun 2015 10:50:15 +0200 Subject: add '+' to limited matchdepth - revert "normal" call to optimized-tail-call-recursion for '*', '?' and '-' - add a "pattern too complex" test to !singlematch() branch, so that it is limited on call numbers. --- httpd/patterns.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/httpd/patterns.c b/httpd/patterns.c index 177a5af..e6e1b1f 100644 --- a/httpd/patterns.c +++ b/httpd/patterns.c @@ -425,14 +425,16 @@ 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->matchdepth-- == 0) { + match_error(ms, "pattern too complex"); + s = NULL; /* failed */ + } + /* accept empty? */ if (*ep == '*' || *ep == '?' || *ep == '-') { + p = ep + 1; /* return match(ms, s, ep + 1); */ - return match(ms, s, ep + 1); - /* - * p = ep + 1; - * goto init; - */ + goto init; } else { /* '+' or no suffix */ s = NULL; /* fail */ -- cgit v1.2.3-54-g00ecf