r4538 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Mon Feb 8 19:09:50 CET 2010


Author: phk
Date: 2010-02-08 19:09:49 +0100 (Mon, 08 Feb 2010)
New Revision: 4538

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt.c
Log:
Fix an edge-case in vrt_assemble_string().  You will still run out
of workspace, but the message will make more sense...



Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-02-08 11:53:51 UTC (rev 4537)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c	2010-02-08 18:09:49 UTC (rev 4538)
@@ -156,10 +156,11 @@
 		if (b + x < e)
 			memcpy(b, h, x);
 		b += x;
-		if (b + 1 < e)
-			*b++ = ' ';
+		if (b < e)
+			*b = ' ';
+		b++;
 	}
-	while (p != vrt_magic_string_end) {
+	while (p != vrt_magic_string_end && b < e) {
 		if (p == NULL)
 			p = "(null)";
 		x = strlen(p);
@@ -168,8 +169,9 @@
 		b += x;
 		p = va_arg(ap, const char *);
 	}
-	if (b + 1 < e)
-		*b++ = '\0';
+	if (b < e)
+		*b = '\0';
+	b++;
 	if (b > e) {
 		WS_Release(hp->ws, 0);
 		return (NULL);



More information about the varnish-commit mailing list