Commit c4ca71d3 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Fix an off-by one error in vrt_assemble_string() when we use up exactly

the number of bytes in the workspace.

This is the most obscure test-case I have written so far, and I wonder
how portable it is.  I may have to drop it if it does not work on
systems with different width/alignment requirements.

Fixes: #693



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4830 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent febef2bb
...@@ -179,7 +179,7 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap) ...@@ -179,7 +179,7 @@ vrt_assemble_string(struct http *hp, const char *h, const char *p, va_list ap)
} else { } else {
e = b; e = b;
b = hp->ws->f; b = hp->ws->f;
WS_Release(hp->ws, 1 + e - b); WS_Release(hp->ws, e - b);
return (b); return (b);
} }
} }
......
# $Id$
#
test "check boundary condition on vrt_assemble_string()"
server s1 {
rxreq
expect req.http.baz == "req.http.baz"
txresp -status 201
rxreq
expect req.http.baz == "req.http.baz"
txresp -status 202
rxreq
expect req.http.baz == "BAZ"
txresp -status 203
} -start
varnish v1 -arg "-p sess_workspace=1024" -vcl+backend {
sub vcl_recv {
set req.http.foo =
req.http.bar
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef" "0123456789abcdef"
"0123456789abcdef"
"01234567";
set req.http.baz = "BAZ";
return (pass);
}
sub vcl_hash {
set req.hash += req.url;
return (hash);
}
} -start
client c1 {
# This should soak up all bytes but the last in the workspace
txreq -hdr "foo: x" -hdr "bar: A"
rxresp
expect resp.status == 201
# This should soak up all bytes in the workspace
txreq -hdr "foo: x" -hdr "bar: AB"
rxresp
expect resp.status == 202
# This overcommits the workspace, failing the "bar" set,
# Thus allowing the "baz" set to work.
txreq -hdr "foo: x" -hdr "bar: ABC"
rxresp
expect resp.status == 203
} -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