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:
+10
-1
@@ -172,6 +172,15 @@ void command_register(command_t command)
|
|||||||
"options", '+', 1, "read command line options from file"
|
"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++;
|
registered++;
|
||||||
}
|
}
|
||||||
@@ -208,7 +217,7 @@ int command_usage(char *error)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; cmds[active].line[i]; i++)
|
for (i = 0; i < MAX_LINES && cmds[active].line[i]; i++)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
+1
-1
@@ -34,7 +34,7 @@
|
|||||||
/**
|
/**
|
||||||
* Maximum number of usage summary lines (+1)
|
* Maximum number of usage summary lines (+1)
|
||||||
*/
|
*/
|
||||||
#define MAX_LINES 10
|
#define MAX_LINES 11
|
||||||
|
|
||||||
typedef struct command_t command_t;
|
typedef struct command_t command_t;
|
||||||
typedef struct command_option_t command_option_t;
|
typedef struct command_option_t command_option_t;
|
||||||
|
|||||||
+10
-1
@@ -176,6 +176,15 @@ void command_register(command_t command)
|
|||||||
"uri", 'u', 1, "service URI to connect to"
|
"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++;
|
registered++;
|
||||||
}
|
}
|
||||||
@@ -217,7 +226,7 @@ int command_usage(char *error, ...)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
for (i = 0; cmds[active].line[i]; i++)
|
for (i = 0; i < MAX_LINES && cmds[active].line[i]; i++)
|
||||||
{
|
{
|
||||||
if (i == 0)
|
if (i == 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -214,10 +214,9 @@ static void __attribute__ ((constructor))reg()
|
|||||||
{
|
{
|
||||||
command_register((command_t) {
|
command_register((command_t) {
|
||||||
list_certs, 'x', "list-certs", "list stored certificates",
|
list_certs, 'x', "list-certs", "list stored certificates",
|
||||||
{"[--subject <dn/san>] "
|
{"[--subject <dn/san>] [--pem]",
|
||||||
"[--type x509|x509_ac|x509_crl|ocsp_response|pubkey]\n "
|
"[--type x509|x509_ac|x509_crl|ocsp_response|pubkey]",
|
||||||
"[--flag none|ca|aa|ocsp|any] "
|
"[--flag none|ca|aa|ocsp|any] [--raw|--pretty|--short|--utc]"},
|
||||||
"[--pem] [--raw|--pretty|--short|--utc]"},
|
|
||||||
{
|
{
|
||||||
{"help", 'h', 0, "show usage information"},
|
{"help", 'h', 0, "show usage information"},
|
||||||
{"subject", 's', 1, "filter by certificate subject"},
|
{"subject", 's', 1, "filter by certificate subject"},
|
||||||
|
|||||||
Reference in New Issue
Block a user