cli_parse_table_req() accepts "set table <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.
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;