Commit 2177905c by Geoff Simmons

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

and don't work around the previous off-by-one error in WS_Assert_Allocated
any more.
Fixes #3 for master.
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
......@@ -154,7 +154,7 @@ match(VRT_CTX, vre_t *vre, VCL_STRING subject, struct vmod_priv *task)
ov->magic = OV_MAGIC;
}
else {
WS_Assert_Allocated(ctx->ws, task->priv, sizeof(*ov) - 1);
WS_Assert_Allocated(ctx->ws, task->priv, sizeof(*ov));
CAST_OBJ(ov, task->priv, OV_MAGIC);
}
......@@ -215,9 +215,9 @@ backref(VRT_CTX, VCL_INT refnum, VCL_STRING fallback, struct vmod_priv *task)
if (task->len <= 0)
return fallback;
WS_Assert_Allocated(ctx->ws, task->priv, sizeof(*ov) - 1);
WS_Assert_Allocated(ctx->ws, task->priv, sizeof(*ov));
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));
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