aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTobias Brunner <tobias@strongswan.org>2015-12-16 12:28:22 +0100
committerTobias Brunner <tobias@strongswan.org>2015-12-16 12:28:22 +0100
commit891e9e95ea7644abf7203d0357ced7d2f8680c77 (patch)
tree416283e2fadc587b331a57ffaa05c492e9b62611 /src
parentbf5754adcd720dbce09830176ba274f93196b8b7 (diff)
parent3f2c3052267662521383d8b0cdb1e33907073e0a (diff)
downloadstrongswan-891e9e95ea7644abf7203d0357ced7d2f8680c77.tar.bz2
strongswan-891e9e95ea7644abf7203d0357ced7d2f8680c77.tar.xz
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.
Diffstat (limited to 'src')
-rw-r--r--src/pki/command.c11
-rw-r--r--src/pki/command.h2
-rw-r--r--src/swanctl/command.c11
-rw-r--r--src/swanctl/commands/list_certs.c7
4 files changed, 24 insertions, 7 deletions
diff --git a/src/pki/command.c b/src/pki/command.c
index 13e81404c..ce704dbb8 100644
--- a/src/pki/command.c
+++ b/src/pki/command.c
@@ -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)
{
diff --git a/src/pki/command.h b/src/pki/command.h
index e55c579e4..449252eb8 100644
--- a/src/pki/command.h
+++ b/src/pki/command.h
@@ -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;
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)
{
diff --git a/src/swanctl/commands/list_certs.c b/src/swanctl/commands/list_certs.c
index b2ff3b5c7..2c314d8b2 100644
--- a/src/swanctl/commands/list_certs.c
+++ b/src/swanctl/commands/list_certs.c
@@ -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"},