[Varnish] #896: Strings longer than 256 characters are bad handled in VCL
Varnish
varnish-bugs at varnish-cache.org
Thu Apr 7 16:36:59 CEST 2011
#896: Strings longer than 256 characters are bad handled in VCL
-----------------------------------+----------------------------------------
Reporter: tmagnien | Type: defect
Status: new | Priority: normal
Milestone: | Component: varnishd
Version: trunk | Severity: normal
Keywords: string regexp vcl 256 |
-----------------------------------+----------------------------------------
Hi,
While trying my 2.1.5 VCL file on a trunk version, I got errors related to
regexps : Regexp compilation error: missing ).
I made some tests and found that any regexp longer that 256 characters was
failing to compile.
For example, the following line :
{{{
if (req.http.host ~ "^(www.abc.fr|www.def.com|...)$") {
--- do something ---
}
}}}
was failing with a domain list longer than 256 characters.
After investigation, it seems that the problem is in vcc_decstr function :
the length of a string is calculated using an unsigned char, which may not
be enough... This affects all strings in the VCL.
Here is a simple match proposal :
{{{
diff --git a/lib/libvcl/vcc_token.c b/lib/libvcl/vcc_token.c
index 6818777..56c9672 100644
--- a/lib/libvcl/vcc_token.c
+++ b/lib/libvcl/vcc_token.c
@@ -350,7 +350,7 @@ static int
vcc_decstr(struct vcc *tl)
{
char *q;
- unsigned char l;
+ unsigned int l;
assert(tl->t->tok == CSTR);
l = (tl->t->e - tl->t->b) - 2;
}}}
Regards,
Thierry
--
Ticket URL: <http://www.varnish-cache.org/trac/ticket/896>
Varnish <http://varnish-cache.org/>
The Varnish HTTP Accelerator
More information about the varnish-bugs
mailing list