summary refs log tree commit diff
diff options
context:
space:
mode:
authorHerbert Xu <herbert@gondor.apana.org.au>2019-02-25 14:00:31 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2019-03-28 21:18:03 +0800
commit86a841bb444ed1d9a09afb38cb818a21c04e1beb (patch)
tree57d6bf19d3b056aadd20bc427a682b21ad826266
parentoptions: Do not set commandname in procargs (diff)
downloaddash-86a841bb444ed1d9a09afb38cb818a21c04e1beb.tar.gz
dash-86a841bb444ed1d9a09afb38cb818a21c04e1beb.zip
expand: Fix double-decrement in argstr
Due to a double decrement in argstr we may miss field separators
at the end of a word in certain situations.

Reported-by: Martijn Dekker <martijn@inlv.org>
Fixes: 3cd538634f71 ("expand: Do not reprocess data when...")
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
-rw-r--r--src/expand.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/expand.c b/src/expand.c
index af9cac9..e57efa6 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -285,7 +285,7 @@ start:
 			q = stnputs(p, length, expdest);
 			q[-1] &= end - 1;
 			expdest = q - (flag & EXP_WORD ? end : 0);
-			newloc = expdest - (char *)stackblock() - end;
+			newloc = q - (char *)stackblock() - end;
 			if (breakall && !inquotes && newloc > startloc) {
 				recordregion(startloc, newloc, 0);
 			}