[master] a7b80c7c2 Don't assume input buffer is valid after the call
Federico G. Schwindt
fgsch at lodoss.net
Wed Mar 13 15:16:08 UTC 2019
commit a7b80c7c277e1435bdab05fa2313b8fdafb2dc31
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date: Wed Mar 13 14:46:59 2019 +0000
Don't assume input buffer is valid after the call
Patch by @phk, test by yours truly.
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index df30f0e8c..8bea0e81d 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -537,7 +537,7 @@ ved_pretend_gzip_bytes(struct req *req, enum vdp_action act, void **priv,
l -= lx;
p += lx;
}
- /* buf2 is local, have to flush */
+ /* buf1 & buf2 is local, have to flush */
return (ved_bytes(req, ecx, VDP_FLUSH, NULL, 0));
}
@@ -609,8 +609,6 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv,
ssize_t l;
CAST_OBJ_NOTNULL(foo, *priv, VED_FOO_MAGIC);
- (void)req;
- (void)act;
pp = ptr;
if (len > 0) {
/* Skip over the GZIP header */
@@ -630,7 +628,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv,
if (dl > 0) {
if (dl > len)
dl = len;
- if (ved_bytes(req, foo->ecx, VDP_NULL, pp, dl))
+ if (ved_bytes(req, foo->ecx, act, pp, dl))
return(-1);
foo->ll += dl;
len -= dl;
@@ -641,7 +639,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv,
/* Remove the "LAST" bit */
foo->dbits[0] = *pp;
foo->dbits[0] &= ~(1U << (foo->last & 7));
- if (ved_bytes(req, foo->ecx, VDP_NULL, foo->dbits, 1))
+ if (ved_bytes(req, foo->ecx, act, foo->dbits, 1))
return (-1);
foo->ll++;
len--;
@@ -653,7 +651,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv,
if (dl > 0) {
if (dl > len)
dl = len;
- if (ved_bytes(req, foo->ecx, VDP_NULL, pp, dl))
+ if (ved_bytes(req, foo->ecx, act, pp, dl))
return (-1);
foo->ll += dl;
len -= dl;
@@ -715,8 +713,7 @@ ved_gzgz_bytes(struct req *req, enum vdp_action act, void **priv,
default:
WRONG("compiler must be broken");
}
- if (ved_bytes(req, foo->ecx,
- VDP_NULL, foo->dbits + 1, foo->lpad))
+ if (ved_bytes(req, foo->ecx, act, foo->dbits + 1, foo->lpad))
return (-1);
}
if (len > 0) {
diff --git a/bin/varnishtest/tests/e00032.vtc b/bin/varnishtest/tests/e00032.vtc
new file mode 100644
index 000000000..96c9e8deb
--- /dev/null
+++ b/bin/varnishtest/tests/e00032.vtc
@@ -0,0 +1,25 @@
+varnishtest "Exercise ESI+gzip in pass mode"
+
+server s1 {
+ rxreq
+ txresp -gzipbody {<esi:include src="/foo"/>}
+ rxreq
+ txresp -gzipbody "foo"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_recv {
+ return (pass);
+ }
+ sub vcl_backend_response {
+ set beresp.do_esi = true;
+ }
+} -start
+
+client c1 {
+ txreq -hdr "Accept-Encoding: gzip"
+ rxresp
+ expect resp.status == 200
+ gunzip
+ expect resp.bodylen == 3
+} -run
More information about the varnish-commit
mailing list