diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-10-30 09:35:53 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2012-10-30 11:23:59 +0100 |
commit | 57ce4bd4ea3c54317490ad719fad17bc6413c3f6 (patch) | |
tree | 19eaa0f8f6b652fc93bea510143818a3dac43d39 /src/journal/coredumpctl.c | |
parent | 50425d1614bfa47c9f124d87e6d936671970f8c5 (diff) |
coredumpctl: add guard to options table
It is not nice to segfault on unknown options :(
Diffstat (limited to 'src/journal/coredumpctl.c')
-rw-r--r-- | src/journal/coredumpctl.c | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/src/journal/coredumpctl.c b/src/journal/coredumpctl.c index 311c18b6ab..3560534bf6 100644 --- a/src/journal/coredumpctl.c +++ b/src/journal/coredumpctl.c @@ -143,10 +143,11 @@ static int parse_argv(int argc, char *argv[]) { int r, c; static const struct option options[] = { - { "help", no_argument, NULL, 'h' }, - { "version" , no_argument, NULL, ARG_VERSION }, - { "no-pager", no_argument, NULL, ARG_NO_PAGER }, - { "output", required_argument, NULL, 'o' }, + { "help", no_argument, NULL, 'h' }, + { "version" , no_argument, NULL, ARG_VERSION }, + { "no-pager", no_argument, NULL, ARG_NO_PAGER }, + { "output", required_argument, NULL, 'o' }, + { NULL, 0, NULL, 0 } }; assert(argc >= 0); @@ -183,6 +184,10 @@ static int parse_argv(int argc, char *argv[]) { } break; + + case '?': + return -EINVAL; + default: log_error("Unknown option code %c", c); return -EINVAL; |