Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libc Add "--" 'options end' parameter to the sh -c call ...



details:   https://anonhg.NetBSD.org/src/rev/233a9040ef9f
branches:  trunk
changeset: 1024600:233a9040ef9f
user:      kre <kre%NetBSD.org@localhost>
date:      Fri Oct 29 19:27:06 2021 +0000

description:
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

diffstat:

 lib/libc/gen/popen.c     |  6 +++---
 lib/libc/stdlib/system.c |  8 ++++----
 2 files changed, 7 insertions(+), 7 deletions(-)

diffs (56 lines):

diff -r 8c646c7a257d -r 233a9040ef9f lib/libc/gen/popen.c
--- a/lib/libc/gen/popen.c      Fri Oct 29 19:22:55 2021 +0000
+++ b/lib/libc/gen/popen.c      Fri Oct 29 19:27:06 2021 +0000
@@ -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 @@
                /* 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 */
        }
diff -r 8c646c7a257d -r 233a9040ef9f lib/libc/stdlib/system.c
--- a/lib/libc/stdlib/system.c  Fri Oct 29 19:22:55 2021 +0000
+++ b/lib/libc/stdlib/system.c  Fri Oct 29 19:27:06 2021 +0000
@@ -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 @@
        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.



Home | Main Index | Thread Index | Old Index