ostree/config: Check for too many args

Currently it's not an error to provide too many arguments to an ostree
config command. Change it so we print usage information in that case,
and update the unit tests.

Closes: #1743
Approved by: cgwalters
This commit is contained in:
Matthew Leeds authored and Atomic Bot committed 2019-03-01 16:29:44 +00:00
1 parent 656853a98a
commit cfc6046689
2 files changed
+30

No files matched your search

+12
View File
@@ -71,6 +71,7 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
g_autofree char *section = NULL;
g_autofree char *key = NULL;
g_autoptr(GKeyFile) config = NULL;
int correct_argc;
context = g_option_context_new ("(get KEY|set KEY VALUE|unset KEY)");
@@ -85,6 +86,17 @@ ostree_builtin_config (int argc, char **argv, OstreeCommandInvocation *invocatio
op = argv[1];
if (!strcmp (op, "set"))
correct_argc = 4;
else
correct_argc = 3;
if (argc > correct_argc)
{
ot_util_usage_error (context, "Too many arguments given", error);
return FALSE;
}
if (!strcmp (op, "set"))
{
if (opt_group)