From: Olivier Houchard Date: Tue, 17 Nov 2026 12:48:25 +0000 (+0100) Subject: BUG/MEDIUM: stick-tables/cli: "set table" without key must not clear the table X-Git-Tag: v3.5-dev13~34 X-Git-Url: https://git.kaiwu.me/web//%22?a=commitdiff_plain;h=8ff243b2a11c3d9d569fdc5dc8d108f3465eac09;p=haproxy.git BUG/MEDIUM: stick-tables/cli: "set table" without key must not clear the table cli_parse_table_req() accepts "set table " without any "key" nor "ptr" argument and returns 0, so that the table I/O handler runs with the "set" action, which, like "clear", kills all unreferenced entries of the table. So an operator mistyping "set table t" silently wipes the whole table instead of getting an error (the doc's synopsis lists key/ptr as required): > set table t key 10.0.0.1 data.gpc0 1 (x4) > show table t => used:4 > set table t => (no output) > show table t => used:0 Let's return the usage message when "set" is used without key nor ptr. This was introduced in 1.7 by commit f13ebdf28 ("REORG: cli: move table dump/clear/set to stick_table.c") which made "set" use the table I/O handler. Before that, it was a no-op. This should be backported to all stable versions. --- diff --git a/src/stick_table.c b/src/stick_table.c index dd8ee3504..43a3b835d 100644 --- a/src/stick_table.c +++ b/src/stick_table.c @@ -5797,8 +5797,8 @@ static int cli_parse_table_req(char **args, char *payload, struct appctx *appctx return table_process_entry_per_ptr(appctx, args); else if (strncmp(args[3], "data.", 5) == 0) return table_prepare_data_request(appctx, args); - else if (*args[3]) - goto err_args; + else if (*args[3] || ctx->action == STK_CLI_ACT_SET) + goto err_args; /* "set" requires a key or a ptr */ return 0;