Skip to content

Commit

Permalink
nsenter: Fix argument parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
ruihe774 committed Dec 20, 2024
1 parent 96e2fb8 commit 01de3ea
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/ostree/ot-admin-builtin-nsenter.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ ot_admin_builtin_nsenter (int argc, char **argv, OstreeCommandInvocation *invoca

context = g_option_context_new ("[PROGRAM [ARGUMENTS...]]");

int new_argc = argc;
char **new_argv = argv;
int new_argc = 0;
char **new_argv = NULL;

for (int i = 1; i < argc; i++)
{
if (g_str_equal (argv[i], "--"))
{
new_argc -= i;
new_argc = argc - i;
argc = i;
new_argv = argv + i;
argv[i] = NULL;
Expand All @@ -69,8 +69,11 @@ ot_admin_builtin_nsenter (int argc, char **argv, OstreeCommandInvocation *invoca
invocation, &sysroot, cancellable, error))
return FALSE;

argc = new_argc;
argv = new_argv;
if (new_argv)
{
argc = new_argc;
argv = new_argv;
}
if (argc <= 1)
{
arguments = g_malloc_n (2, sizeof (char *));
Expand Down

0 comments on commit 01de3ea

Please sign in to comment.