[4.1] ed1eb98 Relax IP constant parsing

Lasse Karstensen lkarsten at varnish-software.com
Thu Jan 14 15:15:03 CET 2016


commit ed1eb987ee9c2eb6224ff37b719c0df79d93b5a2
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Wed Nov 4 12:00:09 2015 +0000

    Relax IP constant parsing
    
    Fixes #1801.

diff --git a/bin/varnishtest/tests/r01801.vtc b/bin/varnishtest/tests/r01801.vtc
new file mode 100644
index 0000000..7052ead
--- /dev/null
+++ b/bin/varnishtest/tests/r01801.vtc
@@ -0,0 +1,58 @@
+varnishtest "Test parsing IP constants"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend {
+	import ${vmod_std};
+
+	sub vcl_deliver {
+		set resp.http.foo1 = std.ip("..", "1.2.3.4");
+		set resp.http.foo2 = std.ip("..", "1.2.3.4:8000");
+		set resp.http.foo3 = std.ip("..", "1.2.3.4 8000");
+		set resp.http.foo4 = std.ip("..", "::1");
+		set resp.http.foo5 = std.ip("..", "[::1]");
+		set resp.http.foo6 = std.ip("..", "[::1]:8000");
+		set resp.http.bar1 = std.port("1.2.3.4");
+		set resp.http.bar2 = std.port("1.2.3.4:8000");
+		set resp.http.bar3 = std.port("1.2.3.4 8000");
+		set resp.http.bar4 = std.port("::1");
+		set resp.http.bar5 = std.port("[::1]");
+		set resp.http.bar6 = std.port("[::1]:8000");
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.http.foo1 == "1.2.3.4"
+	expect resp.http.foo2 == "1.2.3.4"
+	expect resp.http.foo3 == "1.2.3.4"
+	expect resp.http.foo4 == "::1"
+	expect resp.http.foo5 == "::1"
+	expect resp.http.foo6 == "::1"
+	expect resp.http.bar1 == "80"
+	expect resp.http.bar2 == "8000"
+	expect resp.http.bar3 == "8000"
+	expect resp.http.bar4 == "80"
+	expect resp.http.bar5 == "80"
+	expect resp.http.bar6 == "8000"
+} -run
+
+varnish v1 -errvcl "could not be resolved to an IP address" {
+	import ${vmod_std};
+
+	sub vcl_deliver {
+		set resp.http.foo = std.ip("..", "::1::2");
+	}
+}
+
+varnish v1 -errvcl "could not be resolved to an IP address" {
+	import ${vmod_std};
+
+	sub vcl_deliver {
+		set resp.http.foo = std.ip("..", "1.2.3.4::80");
+	}
+}
diff --git a/lib/libvarnish/vss.c b/lib/libvarnish/vss.c
index 6d1b809..3d40473 100644
--- a/lib/libvarnish/vss.c
+++ b/lib/libvarnish/vss.c
@@ -56,6 +56,7 @@
  * "0.0.0.0" - "0.0.0.0:80"
  * "[::1]" - "[::1]:80"
  * "[::]" - "[::]:80"
+ * "::1"
  *
  * See also RFC5952
  */
@@ -86,6 +87,8 @@ vss_parse(char *str, char **addr, char **port)
 			p = strchr(str, ':');
 		if (p == NULL)
 			return (NULL);
+		if (p[0] == ':' && strchr(&p[1], ':'))
+			return (NULL);
 		if (p == str)
 			*addr = NULL;
 	}



More information about the varnish-commit mailing list