From 868506eb427c9dcc6d869cd4885679be04e1b7dd Mon Sep 17 00:00:00 2001 From: Joe Simmons-Talbott Date: Wed, 22 Mar 2023 14:04:30 -0400 Subject: system: Add "--" after "-c" for sh (BZ #28519) Prevent sh from interpreting a user string as shell options if it starts with '-' or '+'. Since the version of /bin/sh used for testing system() is different from the full-fledged system /bin/sh add support to it for handling "--" after "-c". Add a testcase to ensure the expected behavior. Signed-off-by: Joe Simmons-Talbott Reviewed-by: Adhemerval Zanella --- support/shell-container.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'support') diff --git a/support/shell-container.c b/support/shell-container.c index b1f9e793c1..28437e4206 100644 --- a/support/shell-container.c +++ b/support/shell-container.c @@ -455,7 +455,12 @@ main (int argc, const char **argv) dprintf (stderr, " argv[%d] is `%s'\n", i, argv[i]); if (strcmp (argv[1], "-c") == 0) - run_command_string (argv[2], argv+3); + { + if (strcmp (argv[2], "--") == 0) + run_command_string (argv[3], argv+4); + else + run_command_string (argv[2], argv+3); + } else run_script (argv[1], argv+2); -- cgit 1.4.1