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

If the backend used chunked encoding and sent junk after the gzip

data, the thread would go into a spin.

Fixes	#942
parent a8481d09
......@@ -302,7 +302,7 @@ VGZ_Gunzip(struct vgz *vg, const void **pptr, size_t *plen)
return (VGZ_END);
if (i == Z_BUF_ERROR)
return (VGZ_STUCK);
printf("INFLATE=%d (%s)\n", i, vg->vz.msg);
VSL(SLT_Debug, 0, "Unknown INFLATE=%d (%s)\n", i, vg->vz.msg);
return (VGZ_ERROR);
}
......@@ -629,6 +629,10 @@ vfp_testgzip_bytes(struct sess *sp, struct http_conn *htc, ssize_t bytes)
while (!VGZ_IbufEmpty(vg)) {
VGZ_Obuf(vg, obuf, sizeof obuf);
i = VGZ_Gunzip(vg, &dp, &dl);
if (i == VGZ_END && !VGZ_IbufEmpty(vg)) {
WSP(sp, SLT_FetchError, "Junk after gzip data");
return (-1);
}
if (i != VGZ_OK && i != VGZ_END) {
WSP(sp, SLT_FetchError,
"Invalid Gzip data: %s", vg->vz.msg);
......
varnishtest "#942 junk after gzip from backend"
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 {}
varnish v1 -start
client c1 {
txreq
rxresp
expect resp.status == 503
} -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