diff --git a/src/pki/command.c b/src/pki/command.c index 415e78b10..7ccbd96f4 100644 --- a/src/pki/command.c +++ b/src/pki/command.c @@ -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++; diff --git a/src/pki/command.h b/src/pki/command.h index 3e66a1a26..737f4658d 100644 --- a/src/pki/command.h +++ b/src/pki/command.h @@ -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