diff options
author | Stefan Bühler <stbuehler@web.de> | 2009-08-28 19:30:48 +0000 |
---|---|---|
committer | Stefan Bühler <stbuehler@web.de> | 2009-08-28 19:30:48 +0000 |
commit | 543f8040d305c91e3c19668479c862298cf0235d (patch) | |
tree | 2ee87c66a4d80ba674e15051a97a57422476f182 /src/configparser.y | |
parent | 5ae8685604ff823f59444916f7456fcf9fb8b2c6 (diff) | |
download | lighttpd-git-543f8040d305c91e3c19668479c862298cf0235d.tar.gz |
Print an error if you use too many captures in a regex pattern (fixes #2059)
git-svn-id: svn://svn.lighttpd.net/lighttpd/branches/lighttpd-1.4.x@2614 152afb58-edef-0310-8abb-c4023f1b3aa9
Diffstat (limited to 'src/configparser.y')
-rw-r--r-- | src/configparser.y | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/configparser.y b/src/configparser.y index 03f50f95..b0042c5e 100644 --- a/src/configparser.y +++ b/src/configparser.y @@ -469,7 +469,7 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio case CONFIG_COND_MATCH: { #ifdef HAVE_PCRE_H const char *errptr; - int erroff; + int erroff, captures; if (NULL == (dc->regex = pcre_compile(rvalue->ptr, 0, &errptr, &erroff, NULL))) { @@ -486,6 +486,14 @@ context ::= DOLLAR SRVVARNAME(B) LBRACKET stringop(C) RBRACKET cond(E) expressio fprintf(stderr, "studying regex failed: %s -> %s\n", rvalue->ptr, errptr); ctx->ok = 0; + } else if (0 != (pcre_fullinfo(dc->regex, dc->regex_study, PCRE_INFO_CAPTURECOUNT, &captures))) { + fprintf(stderr, "getting capture count for regex failed: %s\n", + rvalue->ptr); + ctx->ok = 0; + } else if (captures > 9) { + fprintf(stderr, "Too many captures in regex, use (?:...) instead of (...): %s\n", + rvalue->ptr); + ctx->ok = 0; } else { dc->string = buffer_init_buffer(rvalue); } |