summary refs log tree commit diff
diff options
context:
space:
mode:
authorRoy Marples <uberlord@gentoo.org>2007-09-26 13:59:56 +0800
committerHerbert Xu <herbert@gondor.apana.org.au>2007-09-26 13:59:56 +0800
commitd88ed8c49aa7a8560523c0421812258ee6c2591d (patch)
treed296e063b0d55676eed043815e57a36627f5311e
parent[MAN] Clarify syntax of the for command (diff)
downloaddash-d88ed8c49aa7a8560523c0421812258ee6c2591d.tar.gz
dash-d88ed8c49aa7a8560523c0421812258ee6c2591d.zip
[EXPAND] Refresh stack pointers after makestrspace in _rmescapes
dash-0.5.3 has an issue reading some line lengths [1].
This is reproducable on amd64, but not on other arches for some reason.

$ cat bug.sh
(read line; echo "${line%%=*}") <<EOF
TITLE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
EOF
printf "\
TITLE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
" | (read line; echo "${line%%=*}")
$ bash bug.sh
TITLE
TITLE
$ dash bug.sh
TITLE=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx+xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
TITLE

Attahced is a patch to fix the issue

Thanks

Roy

[1] http://bugs.gentoo.org/show_bug.cgi?id=180680
Diffstat (limited to '')
-rw-r--r--ChangeLog4
-rw-r--r--src/expand.c4
2 files changed, 8 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 003a0f7..670682b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2007-09-26  Roy Marples <uberlord@gentoo.org>
+
+	* Refresh stack pointers after makestrspace in _rmescapes.
+
 2007-09-25  Gerrit Pape <pape@smarden.org>
 
 	* Clarify description of -nt, -ot options to test builtin.
diff --git a/src/expand.c b/src/expand.c
index 8c6c7f9..98ad718 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -1631,7 +1631,11 @@ _rmescapes(char *str, int flag)
 		size_t fulllen = len + strlen(p) + 1;
 
 		if (flag & RMESCAPE_GROW) {
+			int strloc = str - (char *)stackblock();
+
 			r = makestrspace(fulllen, expdest);
+			str = (char *)stackblock() + strloc;
+			p = str + len;
 		} else if (flag & RMESCAPE_HEAP) {
 			r = ckmalloc(fulllen);
 		} else {