diff options
author | Sébastien Marie <semarie@users.noreply.github.com> | 2015-06-22 16:52:49 +0200 |
---|---|---|
committer | Sébastien Marie <semarie@users.noreply.github.com> | 2015-06-22 16:54:29 +0200 |
commit | 2e5a82bd8af77e44afb01b1c366641511fdd8099 (patch) | |
tree | 5819785c83ed6e86dbf7e91da71a424898c7b88c | |
parent | a6ac783e163ccffbcd2d28627497a7bb31a9dd3b (diff) | |
download | httpd-2e5a82bd8af77e44afb01b1c366641511fdd8099.tar.gz httpd-2e5a82bd8af77e44afb01b1c366641511fdd8099.zip |
don't do tail-call-recursive every time
- switch '*', '?' and '-' to normal call, in order to pass into "too
complex" check
- remove assert()
- on error, quit early
-rw-r--r-- | httpd/patterns.c | 11 | ||||
-rw-r--r-- | httpd/patterns.h | 2 |
2 files changed, 9 insertions, 4 deletions
diff --git a/httpd/patterns.c b/httpd/patterns.c index 1dbea15..177a5af 100644 --- a/httpd/patterns.c +++ b/httpd/patterns.c @@ -427,9 +427,12 @@ match(struct match_state *ms, const char *s, const char *p) if (!singlematch(ms, s, p, ep)) { /* accept empty? */ if (*ep == '*' || *ep == '?' || *ep == '-') { - p = ep + 1; /* return match(ms, s, ep + 1); */ - goto init; + return match(ms, s, ep + 1); + /* + * p = ep + 1; + * goto init; + */ } else { /* '+' or no suffix */ s = NULL; /* fail */ @@ -621,11 +624,13 @@ str_find_aux(struct match_state *ms, const char *pattern, const char *string, do { const char *res; ms->level = 0; - assert(ms->matchdepth == MAXCCALLS); if ((res = match(ms, s1, p)) != NULL) { sm->sm_so = 0; sm->sm_eo = ls; return push_captures(ms, s1, res, sm + 1, nsm - 1) + 1; + + } else if (ms->error != NULL) { + return 0; } } while (s1++ < ms->src_end && !anchor); diff --git a/httpd/patterns.h b/httpd/patterns.h index ddda0dd..28b0f95 100644 --- a/httpd/patterns.h +++ b/httpd/patterns.h @@ -23,7 +23,7 @@ #define PATTERNS_H #define MAXCAPTURES 32 /* Max no. of allowed captures in pattern */ -#define MAXCCALLS 200 /* Max recusion depth in pattern matching */ +#define MAXCCALLS 5000 /* Max recusion depth in pattern matching */ struct str_find { off_t sm_so; /* start offset of match */ |