pki: Make sure no command registers too many options
This commit is contained in:
+10
-3
@@ -153,17 +153,24 @@ void command_register(command_t command)
|
||||
{
|
||||
for (i = 0; i < countof(cmds[registered].options) - 1; i++)
|
||||
{
|
||||
if (cmds[registered].options[i].name)
|
||||
if (!cmds[registered].options[i].name)
|
||||
{
|
||||
continue;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i > countof(cmds[registered].options) - 3)
|
||||
{
|
||||
fprintf(stderr, "command '%s' registered too many options, please "
|
||||
"increase MAX_OPTIONS\n", command.cmd);
|
||||
}
|
||||
else
|
||||
{
|
||||
cmds[registered].options[i++] = (command_option_t) {
|
||||
"debug", 'v', 1, "set debug level, default: 1"
|
||||
};
|
||||
cmds[registered].options[i++] = (command_option_t) {
|
||||
"options", '+', 1, "read command line options from file"
|
||||
};
|
||||
break;
|
||||
}
|
||||
}
|
||||
registered++;
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@
|
||||
#define MAX_COMMANDS 11
|
||||
|
||||
/**
|
||||
* Maximum number of options in a command (+1)
|
||||
* Maximum number of options in a command (+3)
|
||||
*/
|
||||
#define MAX_OPTIONS 32
|
||||
|
||||
|
||||
Reference in New Issue
Block a user