aboutsummaryrefslogtreecommitdiff
path: root/httpd
diff options
context:
space:
mode:
authorReyk Floeter <reyk@esdenera.com>2015-06-23 13:15:49 +0200
committerReyk Floeter <reyk@esdenera.com>2015-06-23 13:15:49 +0200
commitd0ff6c5d27b28a2a77e9411a929f500c79e647f8 (patch)
tree06cad3a063b128c6fc7d2377750863e30b383f6e /httpd
parent27068d85acf018899883abbeb23abcefe48ded1f (diff)
parent3873b23c53de31074d294d127077e691662150c2 (diff)
downloadhttpd-d0ff6c5d27b28a2a77e9411a929f500c79e647f8.tar.gz
httpd-d0ff6c5d27b28a2a77e9411a929f500c79e647f8.zip
Merge branch 'experiment-2' into patterns
Diffstat (limited to 'httpd')
-rw-r--r--httpd/patterns.c13
-rw-r--r--httpd/patterns.h3
2 files changed, 9 insertions, 7 deletions
diff --git a/httpd/patterns.c b/httpd/patterns.c
index e6e1b1f..08c1e27 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,13 +426,12 @@ 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 */
- }
-
+ if (ms->repetitioncounter-- == 0) {
+ match_error(ms, "max repetition items");
+ s = NULL; /* fail */
/* accept empty? */
- if (*ep == '*' || *ep == '?' || *ep == '-') {
+ } else if
+ (*ep == '*' || *ep == '?' || *ep == '-') {
p = ep + 1;
/* return match(ms, s, ep + 1); */
goto init;
@@ -620,6 +620,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;
diff --git a/httpd/patterns.h b/httpd/patterns.h
index 28b0f95..6db5991 100644
--- a/httpd/patterns.h
+++ b/httpd/patterns.h
@@ -23,7 +23,8 @@
#define PATTERNS_H
#define MAXCAPTURES 32 /* Max no. of allowed captures in pattern */
-#define MAXCCALLS 5000 /* Max recusion depth in pattern matching */
+#define MAXCCALLS 200 /* Max recusion depth in pattern matching */
+#define MAXREPETITION 0xfffff /* Max for repetition items */
struct str_find {
off_t sm_so; /* start offset of match */