Commit 7bcd7cce authored by Geoff Simmons's avatar Geoff Simmons

match now checks for regex compilation errors, and logs them if needed

parent ff4d7838
varnishtest "regex compilation failre"
server s1 {
rxreq
txresp -hdr "Foo: bar" -body "foobar"
} -start
varnish v1 -vcl+backend {
import re from "${vmod_topbuild}/src/.libs/libvmod_re.so";
sub vcl_fetch {
if (re.match(beresp.http.foo, "(")) {
set beresp.http.foo = "baz";
}
}
} -start
client c1 {
txreq
rxresp
expect resp.http.content-length == 6
expect resp.http.foo == "bar"
} -run
......@@ -127,15 +127,26 @@ vmod_match(struct sess *sp, struct vmod_priv *priv_vcl,
str = "";
if (priv_call->priv == NULL) {
int erroffset = 0;
const char *error = NULL;
AZ(pthread_mutex_lock(&re_mutex));
if (priv_call->priv == NULL) {
VRT_re_init(&priv_call->priv, pattern);
priv_call->free = VRT_re_fini;
priv_call->priv = VRE_compile(pattern, 0, &error,
&erroffset);
if (priv_call->priv == NULL)
WSP(sp, SLT_VCL_error,
"vmod re: error compiling regex [%s]: "
"%s at position %d", pattern, error,
erroffset);
else
priv_call->free = VRT_re_fini;
}
AZ(pthread_mutex_unlock(&re_mutex));
}
re = (vre_t *) priv_call->priv;
AN(re);
if (re == NULL)
return 0;
s = VRE_exec(re, str, strlen(str), 0, 0, &tbl->sess[sp->id].ovector[0],
MAX_OV, &params->vre_limits);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment