Commit b4497cfd authored by Geoff Simmons's avatar Geoff Simmons

Fix an off-by-one error checking the allocation of subject in task data.

Fixes #3 for 5.1.
parent 2c142833
......@@ -143,3 +143,37 @@ client c1 {
expect resp.http.frap == "_barf_frap_"
expect resp.http.frapd == "_barf_frap_"
} -run
# Test copying the subject into private task-scoped data
varnish v1 -vcl {
import re from "${vmod_topbuild}/src/.libs/libvmod_re.so";
backend b { .host = "${bad_ip}"; }
sub vcl_init {
new bar = re.regex("bar");
}
sub vcl_recv {
return(synth(200));
}
sub vcl_synth {
if (bar.match("bar45678")) {
set resp.http.bar8 = bar.backref(0);
}
if (bar.match("bar456789")) {
set resp.http.bar9 = bar.backref(0);
}
if (bar.match("bar4567")) {
set resp.http.bar7 = bar.backref(0);
}
}
}
client c1 {
txreq
rxresp
expect resp.http.bar7 == "bar"
expect resp.http.bar8 == "bar"
expect resp.http.bar9 == "bar"
} -run
......@@ -217,7 +217,7 @@ backref(VRT_CTX, VCL_INT refnum, VCL_STRING fallback, struct vmod_priv *task)
WS_Assert_Allocated(ctx->ws, task->priv, sizeof(*ov) - 1);
CAST_OBJ(ov, task->priv, OV_MAGIC);
WS_Assert_Allocated(ctx->ws, ov->subject, -1);
WS_Assert_Allocated(ctx->ws, ov->subject, strlen(ov->subject) - 1);
refnum <<= 1;
assert(refnum + 1 < MAX_OV_USED);
......
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