Source-Changes-HG archive

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

[src/trunk]: src/bin/sh PR bin/52090 - fix expansion of unquoted $*



details:   https://anonhg.NetBSD.org/src/rev/2a2eb6c1fe53
branches:  trunk
changeset: 822439:2a2eb6c1fe53
user:      kre <kre%NetBSD.org@localhost>
date:      Mon Mar 20 11:48:01 2017 +0000

description:
PR bin/52090 - fix expansion of unquoted $*

diffstat:

 bin/sh/expand.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 1aee15b26cf0 -r 2a2eb6c1fe53 bin/sh/expand.c
--- a/bin/sh/expand.c   Mon Mar 20 11:32:51 2017 +0000
+++ b/bin/sh/expand.c   Mon Mar 20 11:48:01 2017 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: expand.c,v 1.103 2017/03/20 11:26:07 kre Exp $ */
+/*     $NetBSD: expand.c,v 1.104 2017/03/20 11:48:01 kre Exp $ */
 
 /*-
  * Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
 #if 0
 static char sccsid[] = "@(#)expand.c   8.5 (Berkeley) 5/15/95";
 #else
-__RCSID("$NetBSD: expand.c,v 1.103 2017/03/20 11:26:07 kre Exp $");
+__RCSID("$NetBSD: expand.c,v 1.104 2017/03/20 11:48:01 kre Exp $");
 #endif
 #endif /* not lint */
 
@@ -947,8 +947,13 @@
                sep = ifsval()[0];
                for (ap = shellparam.p ; (p = *ap++) != NULL ; ) {
                        STRTODEST(p);
-                       if (*ap && sep)
+                       if (!*ap)
+                               break;
+                       if (sep)
                                STPUTC(sep, expdest);
+                       else if ((flag & (EXP_FULL|EXP_IN_QUOTES)) == EXP_FULL
+                           && !quoted && **ap != '\0')
+                               STPUTC('\0', expdest);
                }
                break;
        case '0':



Home | Main Index | Thread Index | Old Index