When a command is parsed to split it in an array of arguments, by default,
at most 64 arguments are supported. But no warning was emitted when there
were too many arguments. Instead, the arguments above the limit were
silently ignored. It could be an issue for some commands, like "add server",
because there was no way to know some arguments were ignored.
Now an error is issued when too many arguments are passed and the command is
not executed.
This patch should be backported to all stable versions.
(cherry picked from commit
d3f92894471dd7306f857156a5820c53c10f8d88)
Signed-off-by: Willy Tarreau <w@1wt.eu>
(cherry picked from commit
cb0fbd5e1a7cdde5210fea8ef87ede21c431807d)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
}
/* fill unused slots */
p = b_tail(&appctx->inbuf);
+
+ /* throw an error if too many args are provided */
+ if (*p && i == MAX_CLI_ARGS) {
+ char *err = NULL;
+
+ cli_err(appctx, memprintf(&err, "Too many arguments. Commands must have at most %d arguments.\n", MAX_CLI_ARGS));
+ return 0;
+ }
+
+
for (; i < MAX_CLI_ARGS + 1; i++)
args[i] = p;