[master] c654ff9 Complain if there are sub-arguments to the -a protocol specs which don't understand them.

Poul-Henning Kamp phk at FreeBSD.org
Mon Aug 3 12:42:52 CEST 2015


commit c654ff91a1287d36ac5c61599cb4ae3d6be22236
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon Aug 3 10:28:48 2015 +0000

    Complain if there are sub-arguments to the -a protocol specs which don't
    understand them.
    
    Fixes: #1770

diff --git a/bin/varnishd/mgt/mgt_acceptor.c b/bin/varnishd/mgt/mgt_acceptor.c
index f0e9a21..0c28a13 100644
--- a/bin/varnishd/mgt/mgt_acceptor.c
+++ b/bin/varnishd/mgt/mgt_acceptor.c
@@ -192,9 +192,13 @@ MAC_Arg(const char *arg)
 	if (av[2] == NULL || !strcmp(av[2], "HTTP/1")) {
 		mh->first_step = S_STP_H1NEWSESS;
 		mh->proto_name = "HTTP/1";
+		if (av[2] != NULL && av[3] != NULL)
+			ARGV_ERR("Too many sub-arguments to -a(HTTP/1))\n");
 	} else if (!strcmp(av[2], "PROXY")) {
 		mh->first_step = S_STP_PROXYNEWSESS;
 		mh->proto_name = "PROXY";
+		if (av[3] != NULL)
+			ARGV_ERR("Too many sub-arguments to -a(PROXY))\n");
 	} else {
 		ARGV_ERR("Unknown protocol '%s'\n", av[2]);
 	}
diff --git a/bin/varnishtest/tests/r01770.vtc b/bin/varnishtest/tests/r01770.vtc
new file mode 100644
index 0000000..774b050
--- /dev/null
+++ b/bin/varnishtest/tests/r01770.vtc
@@ -0,0 +1,5 @@
+varnishtest "bad protocol specs for -a"
+
+err_shell "Too many sub-arguments" "${varnishd} -a 127.0.0.1:80000,PROXY,FOO -d 2>&1"
+err_shell "Too many sub-arguments" "${varnishd} -a 127.0.0.1:80000,HTTP/1,FOO -d 2>&1"
+err_shell "Too many sub-arguments" "${varnishd} -a 127.0.0.1:80000,HTTP/1 -d 2>&1"



More information about the varnish-commit mailing list