r4830 - in trunk/varnish-cache/bin: varnishd varnishtest/tests
phk at varnish-cache.org
phk at varnish-cache.org
Wed May 19 22:55:22 CEST 2010
Author: phk
Date: 2010-05-19 22:55:22 +0200 (Wed, 19 May 2010)
New Revision: 4830
Added:
trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc
Modified:
trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
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
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-05-19 19:53:52 UTC (rev 4829)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2010-05-19 20:55:22 UTC (rev 4830)
@@ -179,7 +179,7 @@
} else {
e = b;
b = hp->ws->f;
- WS_Release(hp->ws, 1 + e - b);
+ WS_Release(hp->ws, e - b);
return (b);
}
}
Added: trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00693.vtc 2010-05-19 20:55:22 UTC (rev 4830)
@@ -0,0 +1,83 @@
+# $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
More information about the varnish-commit
mailing list