[4.0] 336bd58 Fix WS_Printf off by one error/truncation handling.

Dag Haavi Finstad daghf at varnish-software.com
Thu Mar 13 10:24:23 CET 2014


commit 336bd5861a0340d0729c4b053dfc01e127f2f1da
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date:   Tue Feb 4 12:59:47 2014 +0100

    Fix WS_Printf off by one error/truncation handling.

diff --git a/bin/varnishd/cache/cache_ws.c b/bin/varnishd/cache/cache_ws.c
index 5ed9040..8ef7aca 100644
--- a/bin/varnishd/cache/cache_ws.c
+++ b/bin/varnishd/cache/cache_ws.c
@@ -175,11 +175,12 @@ WS_Printf(struct ws *ws, const char *fmt, ...)
 	p = ws->f;
 	va_start(ap, fmt);
 	v = vsnprintf(p, u, fmt, ap);
-	if (v > u) {
+	va_end(ap);
+	if (v >= u) {
 		WS_Release(ws, 0);
 		p = NULL;
 	} else {
-		WS_Release(ws, v);
+		WS_Release(ws, v + 1);
 	}
 	return (p);
 }



More information about the varnish-commit mailing list