pki: Check length of commands array before accessing command in --help

As --help is counted as command as well, the array is not null-terminated
and we have to check for MAX_COMMANDS.

Fixes #550.
This commit is contained in:
Martin Willi 2014-03-11 19:02:16 +01:00
parent c489c5881a
commit 87e53819a6
1 changed files with 1 additions and 1 deletions

View File

@ -200,7 +200,7 @@ int command_usage(char *error)
fprintf(out, "usage:\n");
if (active == help_idx)
{
for (i = 0; cmds[i].cmd; i++)
for (i = 0; i < MAX_COMMANDS && cmds[i].cmd; i++)
{
fprintf(out, " pki --%-7s (-%c) %s\n",
cmds[i].cmd, cmds[i].op, cmds[i].description);