[PATCH] Fix seg fault in VRT_synth_page when the string list has a NULL pointer as the first element.

Martin Blix Grydeland martin at varnish-software.com
Mon Jul 22 14:20:51 CEST 2013


Fixes: #1287
---
 bin/varnishd/cache/cache_vrt.c   |    3 +--
 bin/varnishtest/tests/r01287.vtc |   21 +++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)
 create mode 100644 bin/varnishtest/tests/r01287.vtc

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index c63be80..3c86a6b 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -422,9 +422,8 @@ VRT_synth_page(const struct vrt_ctx *ctx, unsigned flags, const char *str, ...)
 	vsb = SMS_Makesynth(ctx->req->obj);
 	AN(vsb);
 
-	VSB_cat(vsb, str);
 	va_start(ap, str);
-	p = va_arg(ap, const char *);
+	p = str;
 	while (p != vrt_magic_string_end) {
 		if (p == NULL)
 			p = "(null)";
diff --git a/bin/varnishtest/tests/r01287.vtc b/bin/varnishtest/tests/r01287.vtc
new file mode 100644
index 0000000..8560ce3
--- /dev/null
+++ b/bin/varnishtest/tests/r01287.vtc
@@ -0,0 +1,21 @@
+varnishtest "#1287 - check NULL as first pointer to VRT_synth_page"
+
+server s1 {
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		return (error(200, "OK"));
+	}
+	sub vcl_error {
+		synthetic obj.http.blank;
+		return (deliver);
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.body == "(null)"
+} -run
-- 
1.7.10.4




More information about the varnish-dev mailing list