[master] 6334f5533 Don't rely on unsigned -1 to be huge

Poul-Henning Kamp phk at FreeBSD.org
Thu Apr 18 08:55:08 UTC 2019


commit 6334f55336f96bfeeb8a2ece09ea27812d340934
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Apr 18 07:54:29 2019 +0000

    Don't rely on unsigned -1 to be huge

diff --git a/lib/libvarnish/vcli_serve.c b/lib/libvarnish/vcli_serve.c
index 45363b302..5c95f4f74 100644
--- a/lib/libvarnish/vcli_serve.c
+++ b/lib/libvarnish/vcli_serve.c
@@ -206,11 +206,12 @@ VCLS_func_help_json(struct cli *cli, const char * const *av, void *priv)
 
 static void
 cls_dispatch(struct cli *cli, const struct cli_proto *cp,
-    char * const * av, unsigned ac)
+    char * const * av, int ac)
 {
 	int json = 0;
 
 	AN(av);
+	assert(ac >= 0);
 
 	VSB_clear(cli->sb);
 
@@ -234,7 +235,7 @@ cls_dispatch(struct cli *cli, const struct cli_proto *cp,
 		return;
 	}
 
-	if (ac - 1 > cp->desc->maxarg + json) {
+	if (cp->desc->maxarg >= 0 && ac - 1 > cp->desc->maxarg + json) {
 		VCLI_Out(cli, "Too many parameters\n");
 		VCLI_SetResult(cli, CLIS_TOOMANY);
 		return;
@@ -257,7 +258,7 @@ cls_exec(struct VCLS_fd *cfd, char * const *av)
 	struct VCLS *cs;
 	struct cli_proto *clp;
 	struct cli *cli;
-	unsigned na;
+	int na;
 	ssize_t len;
 	char *s;
 	unsigned lim;


More information about the varnish-commit mailing list