Module Name: src Committed By: kre Date: Fri Oct 29 19:27:07 UTC 2021
Modified Files: src/lib/libc/gen: popen.c src/lib/libc/stdlib: system.c Log Message: Add "--" 'options end' parameter to the sh -c call that runs the command, so that the command cannot appear to be more options (which always then fails, as there would be no arg for "-c" to treat as the command string in that case). For the full (LONG) explanation, see: http://mail-index.netbsd.org/current-users/2021/10/29/msg041629.html To generate a diff of this commit: cvs rdiff -u -r1.36 -r1.37 src/lib/libc/gen/popen.c cvs rdiff -u -r1.25 -r1.26 src/lib/libc/stdlib/system.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libc/gen/popen.c diff -u src/lib/libc/gen/popen.c:1.36 src/lib/libc/gen/popen.c:1.37 --- src/lib/libc/gen/popen.c:1.36 Thu Jan 24 18:01:38 2019 +++ src/lib/libc/gen/popen.c Fri Oct 29 19:27:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: popen.c,v 1.36 2019/01/24 18:01:38 christos Exp $ */ +/* $NetBSD: popen.c,v 1.37 2021/10/29 19:27:06 kre Exp $ */ /* * Copyright (c) 1988, 1993 @@ -37,7 +37,7 @@ #if 0 static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: popen.c,v 1.36 2019/01/24 18:01:38 christos Exp $"); +__RCSID("$NetBSD: popen.c,v 1.37 2021/10/29 19:27:06 kre Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -209,7 +209,7 @@ popen(const char *cmd, const char *type) /* NOTREACHED */ case 0: /* Child. */ pdes_child(pdes, type); - execl(_PATH_BSHELL, "sh", "-c", cmd, NULL); + execl(_PATH_BSHELL, "sh", "-c", "--", cmd, NULL); _exit(127); /* NOTREACHED */ } Index: src/lib/libc/stdlib/system.c diff -u src/lib/libc/stdlib/system.c:1.25 src/lib/libc/stdlib/system.c:1.26 --- src/lib/libc/stdlib/system.c:1.25 Tue Jan 20 18:31:25 2015 +++ src/lib/libc/stdlib/system.c Fri Oct 29 19:27:06 2021 @@ -1,4 +1,4 @@ -/* $NetBSD: system.c,v 1.25 2015/01/20 18:31:25 christos Exp $ */ +/* $NetBSD: system.c,v 1.26 2021/10/29 19:27:06 kre Exp $ */ /* * Copyright (c) 1988, 1993 @@ -34,7 +34,7 @@ #if 0 static char sccsid[] = "@(#)system.c 8.1 (Berkeley) 6/4/93"; #else -__RCSID("$NetBSD: system.c,v 1.25 2015/01/20 18:31:25 christos Exp $"); +__RCSID("$NetBSD: system.c,v 1.26 2021/10/29 19:27:06 kre Exp $"); #endif #endif /* LIBC_SCCS and not lint */ @@ -56,8 +56,8 @@ system(const char *command) struct sigaction intsa, quitsa, sa; sigset_t nmask, omask; int pstat; - const char *argp[] = {"sh", "-c", NULL, NULL}; - argp[2] = command; + const char *argp[] = {"sh", "-c", "--", NULL, NULL}; + argp[3] = command; /* * ISO/IEC 9899:1999 in 7.20.4.6 describes this special case.