aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorReyk Floeter <reyk@esdenera.com>2015-06-23 11:01:51 +0200
committerReyk Floeter <reyk@esdenera.com>2015-06-23 11:01:51 +0200
commit27068d85acf018899883abbeb23abcefe48ded1f (patch)
tree71079f7b74823661e3e7e36c291effa7d0b37eab
parentca5a2bf34a994373a6976865d4f112b8085b8ae8 (diff)
parentcb9aff69125a32fd4327cce7079eb18273356d92 (diff)
downloadhttpd-27068d85acf018899883abbeb23abcefe48ded1f.tar.gz
httpd-27068d85acf018899883abbeb23abcefe48ded1f.zip
Merge commit 'cb9aff69125a32fd4327cce7079eb18273356d92' into patterns
-rw-r--r--httpd/patterns.c13
-rw-r--r--httpd/patterns.h2
2 files changed, 11 insertions, 4 deletions
diff --git a/httpd/patterns.c b/httpd/patterns.c
index 1dbea15..e6e1b1f 100644
--- a/httpd/patterns.c
+++ b/httpd/patterns.c
@@ -425,11 +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;
+ p = ep + 1;
/* return match(ms, s, ep + 1); */
- goto init;
+ goto init;
} else {
/* '+' or no suffix */
s = NULL; /* fail */
@@ -621,11 +626,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 */