aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2015-12-16 11:56:44 +0100
committerTobias Brunner <tobias@strongswan.org>2015-12-16 12:09:20 +0100
commitb0f00b2a3cf5ca095a9a568dc02aaa4b66e76552 (patch)
treebc666433adc47474cef5699a9b50b88159d52af1
parent50e190e8add8c36da39865d604a96897786cb5d4 (diff)
downloadstrongswan-b0f00b2a3cf5ca095a9a568dc02aaa4b66e76552.tar.bz2
strongswan-b0f00b2a3cf5ca095a9a568dc02aaa4b66e76552.tar.xz
swanctl: Never print more than MAX_LINES of usage summary
Print a warning if a registered command exceeds that limit.
-rw-r--r--src/swanctl/command.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/swanctl/command.c b/src/swanctl/command.c
index 26c41346c..fd9bc0083 100644
--- a/src/swanctl/command.c
+++ b/src/swanctl/command.c
@@ -176,6 +176,15 @@ void command_register(command_t command)
"uri", 'u', 1, "service URI to connect to"
};
}
+ for (i = 0; cmds[registered].line[i]; i++)
+ {
+ if (i == MAX_LINES - 1)
+ {
+ fprintf(stderr, "command '%s' specifies too many usage summary "
+ "lines, please increase MAX_LINES\n", command.cmd);
+ break;
+ }
+ }
}
registered++;
}
@@ -217,7 +226,7 @@ int command_usage(char *error, ...)
}
else
{
- for (i = 0; cmds[active].line[i]; i++)
+ for (i = 0; i < MAX_LINES && cmds[active].line[i]; i++)
{
if (i == 0)
{