klibc-bot for Herbert Xu
2020-Mar-28 21:49 UTC
[klibc] [klibc:update-dash] dash: expand: Fix bugs with words connected to the right of $@
Commit-ID: f4d7a34b1ec9a2238179a48eac757478736c9ca6 Gitweb: http://git.kernel.org/?p=libs/klibc/klibc.git;a=commit;h=f4d7a34b1ec9a2238179a48eac757478736c9ca6 Author: Herbert Xu <herbert at gondor.apana.org.au> AuthorDate: Thu, 22 Mar 2018 17:32:55 +0800 Committer: Ben Hutchings <ben at decadent.org.uk> CommitDate: Sat, 28 Mar 2020 21:42:54 +0000 [klibc] dash: expand: Fix bugs with words connected to the right of $@ [ dash commit f88078247635fd076c935af6413f75395d5159da ] On Sun, Mar 04, 2018 at 12:44:59PM +0100, Harald van Dijk wrote:> > command: set -- a ""; space=" "; printf "<%s>" "$@"$space > bash: <a><> > dash 0.5.8: <a>< > > dash 0.5.9.1: <a>< > > dash patched: <a><>This is actually composed of two bugs. First of all our tracking of quotemark is wrong so anything after "$@" becomes quoted. Once we fix that then the problem is that the first space character after "$@" is not recognised as an IFS. This patch fixes both. Signed-off-by: Herbert Xu <herbert at gondor.apana.org.au> Signed-off-by: Ben Hutchings <ben at decadent.org.uk> --- usr/dash/expand.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/usr/dash/expand.c b/usr/dash/expand.c index 2c29ea44..b3fdc11f 100644 --- a/usr/dash/expand.c +++ b/usr/dash/expand.c @@ -318,13 +318,13 @@ start: case CTLENDVAR: /* ??? */ goto breakloop; case CTLQUOTEMARK: - inquotes ^= EXP_QUOTED; /* "$@" syntax adherence hack */ - if (inquotes && !memcmp(p, dolatstr + 1, - DOLATSTRLEN - 1)) { - p = evalvar(p + 1, flag | inquotes) + 1; + if (!inquotes && !memcmp(p, dolatstr + 1, + DOLATSTRLEN - 1)) { + p = evalvar(p + 1, flag | EXP_QUOTED) + 1; goto start; } + inquotes ^= EXP_QUOTED; addquote: if (flag & QUOTES_ESC) { p--; @@ -1032,7 +1032,10 @@ ifsbreakup(char *string, int maxargs, struct arglist *arglist) realifs = ifsset() ? ifsval() : defifs; ifsp = &ifsfirst; do { + int afternul; + p = string + ifsp->begoff; + afternul = nulonly; nulonly = ifsp->nulonly; ifs = nulonly ? nullstr : realifs; ifsspc = 0; @@ -1097,7 +1100,7 @@ ifsbreakup(char *string, int maxargs, struct arglist *arglist) } if (isifs) { - if (!nulonly) + if (!(afternul || nulonly)) ifsspc = isdefifs; /* Ignore IFS whitespace at start */ if (q == start && ifsspc) {
Maybe Matching Threads
- [klibc:update-dash] expand: Fix bugs with words connected to the right of $@
- [klibc:update-dash] builtin: Fix handling of trailing IFS white spaces
- [klibc:update-dash] dash: builtin: Fix handling of trailing IFS white spaces
- [klibc:update-dash] expand: Fix ghost fields with unquoted $@/$*
- [klibc:update-dash] dash: expand: Fix ghost fields with unquoted $@/$*