[master] 16e98e969 Use req->ws in the ctx when piping
Nils Goroll
nils.goroll at uplex.de
Mon Jan 11 14:26:03 UTC 2021
commit 16e98e9695dce19fc7c9523ea6118bedc7c5bc27
Author: Reza Naghibi <reza at naghibi.com>
Date: Fri Sep 11 10:19:57 2020 -0400
Use req->ws in the ctx when piping
Previously bo->ws was used which led to workspace mixing. req->ws safely
outlives both the bo and req object when piping.
diff --git a/bin/varnishd/cache/cache_vrt_vcl.c b/bin/varnishd/cache/cache_vrt_vcl.c
index 9b4d44c3c..96537a943 100644
--- a/bin/varnishd/cache/cache_vrt_vcl.c
+++ b/bin/varnishd/cache/cache_vrt_vcl.c
@@ -459,11 +459,13 @@ vcl_call_method(struct worker *wrk, struct req *req, struct busyobj *bo,
VCL_Req2Ctx(&ctx, req);
}
if (bo != NULL) {
- if (req)
- assert(method == VCL_MET_PIPE);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(bo->vcl, VCL_MAGIC);
VCL_Bo2Ctx(&ctx, bo);
+ if (req) {
+ assert(method == VCL_MET_PIPE);
+ ctx.ws = req->ws;
+ }
}
assert(ctx.now != 0);
ctx.specific = specific;
diff --git a/bin/varnishtest/tests/r03329.vtc b/bin/varnishtest/tests/r03329.vtc
new file mode 100644
index 000000000..f3453bb61
--- /dev/null
+++ b/bin/varnishtest/tests/r03329.vtc
@@ -0,0 +1,18 @@
+varnishtest "Lost reason from pipe to synth"
+
+server s1 {} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ return (pipe);
+ }
+ sub vcl_pipe {
+ return (synth(505, req.http.foo + "/bar"));
+ }
+} -start
+
+client c1 {
+ txreq -hdr "foo: foo"
+ rxresp
+ expect resp.reason == "foo/bar"
+} -run
diff --git a/bin/varnishtest/tests/r03385.vtc b/bin/varnishtest/tests/r03385.vtc
new file mode 100644
index 000000000..cee34301f
--- /dev/null
+++ b/bin/varnishtest/tests/r03385.vtc
@@ -0,0 +1,23 @@
+varnishtest "Use a priv in vcl_pipe"
+
+server s1 {
+ rxreq
+ txresp
+} -start
+
+varnish v1 -vcl+backend {
+ import debug;
+
+ sub vcl_recv {
+ return (pipe);
+ }
+
+ sub vcl_pipe {
+ debug.test_priv_task();
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+} -run
More information about the varnish-commit
mailing list