r2743 - in trunk/varnish-cache/bin: varnishd varnishtest/tests

phk at projects.linpro.no phk at projects.linpro.no
Fri Jun 20 14:43:45 CEST 2008


Author: phk
Date: 2008-06-20 14:43:45 +0200 (Fri, 20 Jun 2008)
New Revision: 2743

Added:
   trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc
Modified:
   trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
Log:
Make regsub() return an empty string if it gets no input.

Fixes ticket 251 (regression test added)



Modified: trunk/varnish-cache/bin/varnishd/cache_vrt_re.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt_re.c	2008-06-20 12:25:25 UTC (rev 2742)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt_re.c	2008-06-20 12:43:45 UTC (rev 2743)
@@ -115,6 +115,8 @@
 	unsigned u, x;
 
 	AN(re);
+	if (str == NULL)
+		return ("");
 	t = re;
 	i = regexec(t, str, 10, pm, 0);
 

Added: trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc	                        (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/r00251.vtc	2008-06-20 12:43:45 UTC (rev 2743)
@@ -0,0 +1,33 @@
+# $Id$
+
+test "Regression test for #251: segfault on regsub on missing http header"
+
+server s1 {
+	rxreq 
+	txresp \
+		-hdr "Foobar: _barf_" \
+		-hdr "Connection: close" \
+		-body "012345\n"
+}
+
+varnish v1 -vcl+backend { 
+	sub vcl_fetch {
+		set obj.http.Snafu1 =
+		    "zoom"
+		    regsub(obj.http.Foomble, "ar", "\0\0")
+		    "box";
+	}
+} -start 
+
+server s1 -start 
+
+client c1 {
+	txreq -url "/"
+	rxresp
+	expect resp.status == 200
+	expect resp.http.X-Varnish == "1001"
+	expect resp.http.foobar == "_barf_"
+	expect resp.http.snafu1 == "zoombox"
+}
+
+client c1 -run




More information about the varnish-commit mailing list