mirror of
git://sourceware.org/git/lvm2.git
synced 2025-01-03 05:18:29 +03:00
commands: reduce command structure size more
Check for internal limits, if they would ever need to be raised report error message and fail parsing.
This commit is contained in:
parent
8965fd18aa
commit
f1e80f3be0
@ -941,12 +941,28 @@ static void _add_opt_arg(struct command *cmd, char *str,
|
|||||||
}
|
}
|
||||||
|
|
||||||
skip:
|
skip:
|
||||||
if (required > 0)
|
if (required > 0) {
|
||||||
|
if (cmd->ro_count >= CMD_RO_ARGS) {
|
||||||
|
log_error("Too many args, increase CMD_RO_ARGS.");
|
||||||
|
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
cmd->required_opt_args[cmd->ro_count++].opt = opt;
|
cmd->required_opt_args[cmd->ro_count++].opt = opt;
|
||||||
else if (!required)
|
} else if (!required) {
|
||||||
|
if (cmd->oo_count >= CMD_OO_ARGS) {
|
||||||
|
log_error("Too many args, increase CMD_OO_ARGS.");
|
||||||
|
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
cmd->optional_opt_args[cmd->oo_count++].opt = opt;
|
cmd->optional_opt_args[cmd->oo_count++].opt = opt;
|
||||||
else if (required < 0)
|
} else if (required < 0) {
|
||||||
|
if (cmd->io_count >= CMD_IO_ARGS) {
|
||||||
|
log_error("Too many args, increase CMD_IO_ARGS.");
|
||||||
|
cmd->cmd_flags |= CMD_FLAG_PARSE_ERROR;
|
||||||
|
return;
|
||||||
|
}
|
||||||
cmd->ignore_opt_args[cmd->io_count++].opt = opt;
|
cmd->ignore_opt_args[cmd->io_count++].opt = opt;
|
||||||
|
}
|
||||||
|
|
||||||
*takes_arg = opt_names[opt].val_enum ? 1 : 0;
|
*takes_arg = opt_names[opt].val_enum ? 1 : 0;
|
||||||
}
|
}
|
||||||
|
@ -152,12 +152,12 @@ struct cmd_rule {
|
|||||||
* of which one is required after which the rest are
|
* of which one is required after which the rest are
|
||||||
* optional.
|
* optional.
|
||||||
*/
|
*/
|
||||||
#define CMD_RO_ARGS 64 /* required opt args */
|
#define CMD_RO_ARGS 32 /* required opt args */
|
||||||
#define CMD_OO_ARGS 100 /* optional opt args */
|
#define CMD_OO_ARGS 64 /* optional opt args */
|
||||||
#define CMD_RP_ARGS 8 /* required positional args */
|
#define CMD_RP_ARGS 8 /* required positional args */
|
||||||
#define CMD_OP_ARGS 8 /* optional positional args */
|
#define CMD_OP_ARGS 8 /* optional positional args */
|
||||||
#define CMD_IO_ARGS 8 /* ignore opt args */
|
#define CMD_IO_ARGS 8 /* ignore opt args */
|
||||||
#define CMD_MAX_RULES 32 /* max number of rules per command def */
|
#define CMD_MAX_RULES 16 /* max number of rules per command def */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* one or more from required_opt_args is required,
|
* one or more from required_opt_args is required,
|
||||||
|
Loading…
Reference in New Issue
Block a user