[4.1] fc9b45f Fail if multiple -a arguments return the same suckaddr.

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


commit fc9b45f167b2b5c1b206e8bdaf4a00e06617c654
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Nov 2 11:47:44 2015 +0000

    Fail if multiple -a arguments return the same suckaddr.
    
    Fixes	#1813

diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index 658aca4..49cc0c8 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -128,6 +128,13 @@ mac_callback(void *priv, const struct suckaddr *sa)
 
 	CAST_OBJ_NOTNULL(mh, priv, MAC_HELP_MAGIC);
 
+	VTAILQ_FOREACH(ls, &heritage.socks, list) {
+		if (!VSA_Compare(sa, ls->addr)) {
+			ARGV_ERR("-a arguments %s and %s have same address\n",
+			    ls->name, mh->name);
+			return (-1);
+		}
+	}
 	ALLOC_OBJ(ls, LISTEN_SOCK_MAGIC);
 	AN(ls);
 	ls->sock = -1;
diff --git a/bin/varnishtest/tests/r01813.vtc b/bin/varnishtest/tests/r01813.vtc
new file mode 100644
index 0000000..f37aa54
--- /dev/null
+++ b/bin/varnishtest/tests/r01813.vtc
@@ -0,0 +1,3 @@
+varnishtest "Duplicate -a arguments"
+
+err_shell {have same address} "${varnishd} -d -a 127.0.0.1:38484 -a 127.0.0.1:38484 -b localhost:80 2>&1"



More information about the varnish-commit mailing list