[master] 9171f0c Introduction of '-' CLI prefix allowed empty commands to sneak through.

Poul-Henning Kamp phk at FreeBSD.org
Tue May 22 13:11:10 UTC 2018


commit 9171f0ca77f094fa483f2e0e50803b2d9270b8e7
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue May 22 13:09:31 2018 +0000

    Introduction of '-' CLI prefix allowed empty commands to sneak through.
    
    Fixes #2647

diff --git a/bin/varnishtest/tests/r02647.vtc b/bin/varnishtest/tests/r02647.vtc
new file mode 100644
index 0000000..09c63ce
--- /dev/null
+++ b/bin/varnishtest/tests/r02647.vtc
@@ -0,0 +1,15 @@
+varnishtest "empty cli command"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+varnish v1 -clierr 100 "-"
+
+client c1 {
+	txreq
+	rxresp
+} -run
diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c
index 5171d31..b1084a1 100644
--- a/lib/libvarnish/vcli_serve.c
+++ b/lib/libvarnish/vcli_serve.c
@@ -278,6 +278,12 @@ cls_exec(struct VCLS_fd *cfd, char * const *av)
 			break;
 		}
 
+		if (av[1] == NULL) {
+			VCLI_Out(cli, "Empty CLI command.\n");
+			VCLI_SetResult(cli, CLIS_SYNTAX);
+			break;
+		}
+
 		if (isupper(av[1][0])) {
 			VCLI_Out(cli, "all commands are in lower-case.\n");
 			VCLI_SetResult(cli, CLIS_UNKNOWN);


More information about the varnish-commit mailing list