Merge branch 'command-max-lines'

Make sure commands registered in pki and swanctl don't exceed the
maximum number of lines available for their usage summary.

Closes strongswan/strongswan#22.
This commit is contained in:
Tobias Brunner
2015-12-16 12:28:22 +01:00
4 changed files with 24 additions and 7 deletions
+10 -1
View File
@@ -172,6 +172,15 @@ void command_register(command_t command)
"options", '+', 1, "read command line options from file"
};
}
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++;
}
@@ -208,7 +217,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)
{
+1 -1
View File
@@ -34,7 +34,7 @@
/**
* Maximum number of usage summary lines (+1)
*/
#define MAX_LINES 10
#define MAX_LINES 11
typedef struct command_t command_t;
typedef struct command_option_t command_option_t;
+10 -1
View File
@@ -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)
{
+3 -4
View File
@@ -214,10 +214,9 @@ static void __attribute__ ((constructor))reg()
{
command_register((command_t) {
list_certs, 'x', "list-certs", "list stored certificates",
{"[--subject <dn/san>] "
"[--type x509|x509_ac|x509_crl|ocsp_response|pubkey]\n "
"[--flag none|ca|aa|ocsp|any] "
"[--pem] [--raw|--pretty|--short|--utc]"},
{"[--subject <dn/san>] [--pem]",
"[--type x509|x509_ac|x509_crl|ocsp_response|pubkey]",
"[--flag none|ca|aa|ocsp|any] [--raw|--pretty|--short|--utc]"},
{
{"help", 'h', 0, "show usage information"},
{"subject", 's', 1, "filter by certificate subject"},