diff options
author | 2023-03-22 14:04:30 -0400 | |
---|---|---|
committer | 2023-03-28 10:12:30 -0300 | |
commit | 868506eb427c9dcc6d869cd4885679be04e1b7dd (patch) | |
tree | 11233f242405423c14ff09fe781131696d4c73b0 /libio | |
parent | posix: Fix some crashes in wordexp [BZ #18096] (diff) | |
download | glibc-868506eb427c9dcc6d869cd4885679be04e1b7dd.tar.gz glibc-868506eb427c9dcc6d869cd4885679be04e1b7dd.tar.bz2 glibc-868506eb427c9dcc6d869cd4885679be04e1b7dd.zip |
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 <josimmon@redhat.com>
Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Diffstat (limited to 'libio')
-rw-r--r-- | libio/iopopen.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libio/iopopen.c b/libio/iopopen.c index a64033e60f..4cc405f2de 100644 --- a/libio/iopopen.c +++ b/libio/iopopen.c @@ -87,7 +87,7 @@ spawn_process (posix_spawn_file_actions_t *fa, FILE *fp, const char *command, } err = __posix_spawn (&((_IO_proc_file *) fp)->pid, _PATH_BSHELL, fa, 0, - (char *const[]){ (char*) "sh", (char*) "-c", + (char *const[]){ (char*) "sh", (char*) "-c", (char*) "--", (char *) command, NULL }, __environ); if (err != 0) return err; |