[PATCH 6/8] Don't panic on malformed Vary headers.

Martin Blix Grydeland martin at varnish-software.com
Mon Mar 18 17:57:27 CET 2013


Fixes: #1275

Test case by: Dag Haavi Finstad
---
 bin/varnishd/cache/cache_vary.c  |    6 +++++-
 bin/varnishtest/tests/r01275.vtc |   14 ++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)
 create mode 100644 bin/varnishtest/tests/r01275.vtc

diff --git a/bin/varnishd/cache/cache_vary.c b/bin/varnishd/cache/cache_vary.c
index 2a1cb6d..30d77ed 100644
--- a/bin/varnishd/cache/cache_vary.c
+++ b/bin/varnishd/cache/cache_vary.c
@@ -142,7 +142,11 @@ VRY_Create(struct req *req, const struct http *hp, struct vsb **psb)
 			q++;
 		if (*q == '\0')
 			break;
-		xxxassert(*q == ',');
+		if (*q != ',') {
+			VSLb(req->vsl, SLT_Error, "Malformed Vary header");
+			error = 1;
+			break;
+		}
 		p = q;
 	}
 
diff --git a/bin/varnishtest/tests/r01275.vtc b/bin/varnishtest/tests/r01275.vtc
new file mode 100644
index 0000000..72c7184
--- /dev/null
+++ b/bin/varnishtest/tests/r01275.vtc
@@ -0,0 +1,14 @@
+varnishtest "#1275 - panic with malformed Vary header"
+
+server s1 {
+       rxreq
+       txresp -hdr "Vary: foo bar"
+} -start
+
+varnish v1 -vcl+backend { } -start
+
+client c1 {
+       txreq
+       rxresp
+       expect resp.status == 503
+} -run
-- 
1.7.10.4




More information about the varnish-dev mailing list