[experimental-ims] b64281a Make sure we neuter the next entry after the one we just created to prevent old junk on the workspace from being taken for valid.
Geoff Simmons
geoff at varnish-cache.org
Fri Jul 8 11:47:46 CEST 2011
commit b64281a7a9f7ce74daad6763c9d34a444c8ac00a
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Wed Jun 22 09:29:46 2011 +0000
Make sure we neuter the next entry after the one we just created
to prevent old junk on the workspace from being taken for valid.
diff --git a/bin/varnishd/cache_vary.c b/bin/varnishd/cache_vary.c
index 27abf74..01816f6 100644
--- a/bin/varnishd/cache_vary.c
+++ b/bin/varnishd/cache_vary.c
@@ -209,13 +209,19 @@ VRY_Match(const struct sess *sp, const uint8_t *vary)
oflo = 1;
}
- /* We MUST have space for one entry */
- assert(vsp + ln < sp->wrk->vary_e);
+ /*
+ * We MUST have space for one entry and the end marker
+ * after it, which prevents old junk from confusing us
+ */
+ assert(vsp + ln + 2 < sp->wrk->vary_e);
vbe16enc(vsp, (uint16_t)lh);
memcpy(vsp + 2, vary + 2, vary[2] + 2);
- if (h != NULL && e != NULL)
+ if (h != NULL && e != NULL) {
memcpy(vsp + 2 + vsp[2] + 2, h, e - h);
+ vsp[2 + vary[2] + 2 + (e - h) + 2] = '\0';
+ } else
+ vsp[2 + vary[2] + 2 + 2] = '\0';
i = vry_cmp(&vary, &vsp);
assert(i != 1); /* hdr must be the same now */
More information about the varnish-commit
mailing list