pki: Make sure no command registers too many options

This commit is contained in:
Tobias Brunner
2014-01-23 10:12:24 +01:00
parent 079e6c2b04
commit 040cf911a6
2 changed files with 11 additions and 4 deletions
+10 -3
View File
@@ -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
View File
@@ -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