Commit 9d31f5b4 authored by Nils Goroll's avatar Nils Goroll Committed by Martin Blix Grydeland

Fix missed adjustments to vsl buffer space checks

Refs 8df30240

Fixes #3856
parent 4be07a89
......@@ -382,18 +382,18 @@ VSLbs(struct vsl_log *vsl, enum VSL_tag_e tag, const struct strands *s)
/* including NUL */
l = vmin_t(unsigned, strands_len(s) + 1, mlen);
assert(vsl->wlp < vsl->wle);
assert(vsl->wlp <= vsl->wle);
/* Flush if necessary */
if (VSL_END(vsl->wlp, l) >= vsl->wle)
if (VSL_END(vsl->wlp, l) > vsl->wle)
VSL_Flush(vsl, 1);
assert(VSL_END(vsl->wlp, l) < vsl->wle);
assert(VSL_END(vsl->wlp, l) <= vsl->wle);
mlen = strands_cat(VSL_DATA(vsl->wlp), l, s);
assert(l == mlen);
vsl->wlp = vsl_hdr(tag, vsl->wlp, l, vsl->wid);
assert(vsl->wlp < vsl->wle);
assert(vsl->wlp <= vsl->wle);
vsl->wlr++;
if (DO_DEBUG(DBG_SYNCVSL))
......
varnishtest "Regression test off-by-one in VSLbs"
# vsl_buffer=257 bytes - 2 bytes header -> 255 bytes
varnish v1 -arg "-p vsl_buffer=267" -vcl {
import debug;
backend b None;
sub vcl_recv {
# Assert error in VSLbs(), cache/cache_shmlog.c line 385:
# Condition(vsl->wlp < vsl->wle) not true.
debug.vsl_flush();
set req.http.a =
# 255 = "a: " + 8 * 32 - 4
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789ab";
debug.return_strands("xyz");
# Assert error in VSLbs(), cache/cache_shmlog.c line 390:
# Condition(VSL_END(vsl->wlp, l) < vsl->wle) not true.
debug.vsl_flush();
debug.return_strands(
# 255 = 8 * 32 - 1
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcdef" +
"0123456789abcdef0123456789abcde");
return (synth(200));
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
} -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