Commit 86fc6706 authored by Reza Naghibi's avatar Reza Naghibi Committed by Martin Blix Grydeland

Make sure resp.reason is on workspace before using it in vcl_synth

We can incorrectly reference resp.reason from other sources when
jumping into vcl_synth. This also covers passing in a reason in
vcl_backend_error.
parent 3f3d67d9
......@@ -85,6 +85,14 @@ VRT_synth(VRT_CTX, VCL_INT code, VCL_STRING reason)
return;
}
if (reason && !WS_Inside(ctx->ws, reason, NULL)) {
reason = WS_Copy(ctx->ws, reason, -1);
if (!reason) {
VRT_fail(ctx, "Workspace overflow");
return;
}
}
if (ctx->req == NULL) {
CHECK_OBJ_NOTNULL(ctx->bo, BUSYOBJ_MAGIC);
ctx->bo->err_code = (uint16_t)code;
......
varnishtest "Synth resp.reason race"
varnish v1 -vcl {
backend default none;
sub vcl_backend_error {
set beresp.status = 500;
set beresp.reason = "VCL";
}
sub vcl_deliver {
return (synth(resp.status, resp.reason));
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 500
expect resp.reason == "VCL"
} -run
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