[PATCH] Fix for #1086 - break out of loop in VGZ_WrwGunzip when end of gzip data condition is met

Martin Blix Grydeland martin at varnish-software.com
Sun Jan 22 17:59:28 CET 2012


Fix breaks out of the input data loop when end of gzip data is found,
causing all subsequent input data to be ignored.
---
 bin/varnishd/cache/cache_gzip.c  |    2 +
 bin/varnishtest/tests/r01086.vtc |   41 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 43 insertions(+), 0 deletions(-)
 create mode 100644 bin/varnishtest/tests/r01086.vtc

diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 1b732ca..61eb42c 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -380,6 +380,8 @@ VGZ_WrwGunzip(struct worker *wrk, struct vgz *vg, const void *ibuf,
 			*obufp = 0;
 			VGZ_Obuf(vg, obuf + *obufp, obufl - *obufp);
 		}
+		if (i == VGZ_END)
+			break;
 	} while (!VGZ_IbufEmpty(vg));
 	if (i == VGZ_STUCK)
 		i = VGZ_OK;
diff --git a/bin/varnishtest/tests/r01086.vtc b/bin/varnishtest/tests/r01086.vtc
new file mode 100644
index 0000000..0fabfde
--- /dev/null
+++ b/bin/varnishtest/tests/r01086.vtc
@@ -0,0 +1,41 @@
+varnishtest "#1086 junk after gzip from backend and streaming enabled"
+
+server s1 {
+	rxreq
+	txresp -nolen \
+		-hdr "Content-Encoding: gzip" \
+		-hdr "Transfer-Encoding: Chunked"
+	send "14\r\n"
+		# An empty gzip file:
+		sendhex "1f8b"
+		sendhex "08"
+		sendhex "00"
+		sendhex "00000000"
+		sendhex "00"
+		sendhex "03"
+		sendhex "0300"
+		sendhex "00000000"
+		sendhex "00000000"
+	send "\r\n"
+
+	chunked "FOOBAR"
+
+	chunkedlen 0
+
+} -start
+
+varnish v1 -arg {-p diag_bitmap=0x00010000} -vcl+backend {
+	sub vcl_fetch {
+			set beresp.do_stream = true;
+	}
+}
+
+varnish v1 -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.bodylen == 0
+} -run
+
-- 
1.7.4.1




More information about the varnish-dev mailing list