From: Martin Willi Date: Tue, 11 Mar 2014 18:02:16 +0000 (+0100) Subject: pki: Check length of commands array before accessing command in --help X-Git-Tag: 5.1.3dr1~9 X-Git-Url: https://git.strongswan.org/?p=strongswan.git;a=commitdiff_plain;h=87e53819a6dd6c788fc74f4d9157a987766b6682 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. --- diff --git a/src/pki/command.c b/src/pki/command.c index b6966ee..c2e0a5d 100644 --- a/src/pki/command.c +++ b/src/pki/command.c @@ -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);