diff options
author | Pavel Březina <pbrezina@redhat.com> | 2015-10-29 15:15:15 +0100 |
---|---|---|
committer | Jakub Hrozek <jhrozek@redhat.com> | 2015-10-30 11:50:07 +0100 |
commit | 4940ba14100ad11b0ed1f2a8a4fea5daa34d56ee (patch) | |
tree | ccf4029c15c3e77bd88c7ea48486d698b7bf5fdd | |
parent | c8432ffd4cf29fe209b086ef69eacc9683dc5866 (diff) | |
download | sssd-4940ba14100ad11b0ed1f2a8a4fea5daa34d56ee.tar.gz sssd-4940ba14100ad11b0ed1f2a8a4fea5daa34d56ee.tar.xz sssd-4940ba14100ad11b0ed1f2a8a4fea5daa34d56ee.zip |
sss_tools: do not allow unexpected free argument
Reviewed-by: Pavel Reichl <preichl@redhat.com>
-rw-r--r-- | src/tools/common/sss_tools.c | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/tools/common/sss_tools.c b/src/tools/common/sss_tools.c index abb9dbace..d3073a2e5 100644 --- a/src/tools/common/sss_tools.c +++ b/src/tools/common/sss_tools.c @@ -292,6 +292,7 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline, POPT_AUTOHELP POPT_TABLEEND }; + const char *fopt; char *help; poptContext pc; int ret; @@ -337,9 +338,9 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline, } /* Parse free option which is always required if requested. */ + fopt = poptGetArg(pc); if (_fopt != NULL) { - *_fopt = poptGetArg(pc); - if (*_fopt == NULL) { + if (fopt == NULL) { fprintf(stderr, _("Missing option: %s\n\n"), fopt_help); poptPrintHelp(pc, stderr, 0); ret = EXIT_FAILURE; @@ -353,6 +354,14 @@ int sss_tool_popt_ex(struct sss_cmdline *cmdline, ret = EXIT_FAILURE; goto done; } + + *_fopt = fopt; + } else if (_fopt == NULL && fopt != NULL) { + /* Unexpected free argument. */ + fprintf(stderr, _("Unexpected parameter: %s\n\n"), fopt); + poptPrintHelp(pc, stderr, 0); + ret = EXIT_FAILURE; + goto done; } /* If at least one option is required and not provided, print error. */ |