[master] 41f7a35 Fix an oversight when we closed #942: The exact same condition can happen if we gunzip on fetch.

Poul-Henning Kamp phk at varnish-cache.org
Tue Nov 26 19:51:11 CET 2013


commit 41f7a356e2be38f03428589710d163bd4110d9fd
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Nov 26 18:50:39 2013 +0000

    Fix an oversight when we closed #942:  The exact same condition
    can happen if we gunzip on fetch.

diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 4c845aa..09f1594 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -516,6 +516,8 @@ vfp_gunzip_bytes(struct busyobj *bo, struct http_conn *htc, ssize_t bytes)
 		i = VGZ_Gunzip(vg, &dp, &dl);
 		if (i != VGZ_OK && i != VGZ_END)
 			return(VFP_Error(bo, "Gunzip data error"));
+		if (i == VGZ_END && !VGZ_IbufEmpty(vg))
+			return(VFP_Error(bo, "Junk after gzip data"));
 		VBO_extend(bo, dl);
 	}
 	assert(i == Z_OK || i == Z_STREAM_END);
diff --git a/bin/varnishtest/tests/r00942.vtc b/bin/varnishtest/tests/r00942.vtc
index f4c808a..171ceb3 100644
--- a/bin/varnishtest/tests/r00942.vtc
+++ b/bin/varnishtest/tests/r00942.vtc
@@ -1,9 +1,10 @@
 varnishtest "#942 junk after gzip from backend"
 
-server s1 {
+server s1 -repeat 2 {
 	rxreq
 	txresp -nolen \
 		-hdr "Content-Encoding: gzip" \
+		-hdr "Connection: close" \
 		-hdr "Transfer-Encoding: Chunked"
 	send "14\r\n"
 		# An empty gzip file:
@@ -21,13 +22,17 @@ server s1 {
 	chunked "FOOBAR"
 
 	chunkedlen 0
-
+	expect_close
+	accept
 } -start
 
 varnish v1 \
 	-vcl+backend {
 		sub vcl_backend_response {
 			set beresp.do_stream = false;
+			if (bereq.http.foo == "foo") {
+				set beresp.do_gunzip = true;
+			}
 		}
 }
 
@@ -35,7 +40,13 @@ varnish v1 -cliok "param.set debug +syncvsl"
 varnish v1 -start
 
 client c1 {
-	txreq
+	txreq -url /1
+	rxresp
+	expect resp.status == 503
+} -run
+
+client c1 {
+	txreq -url /2 -hdr "Foo: foo"
 	rxresp
 	expect resp.status == 503
 } -run



More information about the varnish-commit mailing list