From: Tobias Brunner Date: Wed, 16 Dec 2015 10:56:44 +0000 (+0100) Subject: swanctl: Never print more than MAX_LINES of usage summary X-Git-Tag: 5.4.0dr2~10^2~1 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b0f00b2a3cf5ca095a9a568dc02aaa4b66e76552;p=thirdparty%2Fstrongswan.git swanctl: Never print more than MAX_LINES of usage summary Print a warning if a registered command exceeds that limit. --- diff --git a/src/swanctl/command.c b/src/swanctl/command.c index 26c41346c0..fd9bc00831 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) {