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 --- sysdeps/posix/system.c | 1 + 1 file changed, 1 insertion(+) (limited to 'sysdeps/posix') diff --git a/sysdeps/posix/system.c b/sysdeps/posix/system.c index d77720a625..488b95163b 100644 --- a/sysdeps/posix/system.c +++ b/sysdeps/posix/system.c @@ -147,6 +147,7 @@ do_system (const char *line) ret = __posix_spawn (&pid, SHELL_PATH, 0, &spawn_attr, (char *const[]){ (char *) SHELL_NAME, (char *) "-c", + (char *) "--", (char *) line, NULL }, __environ); __posix_spawnattr_destroy (&spawn_attr); -- cgit v1.2.3