DASH Shell discussions
 help / color / mirror / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: dash@vger.kernel.org
Cc: Aurelien Jarno <aurel32@debian.org>,
	Herbert Xu <herbert@gondor.apana.org.au>
Subject: [PATCH dash] [EXPAND] Free IFS state after here document expansion
Date: Sun, 13 Mar 2011 13:48:58 -0500	[thread overview]
Message-ID: <20110313184858.GA6687@elie> (raw)
In-Reply-To: <20110313144103.30026.48296.reportbug@volta.aurel32.net>

Here's another bug bisecting to f42e443bb ([EXPAND] Fix
ifsfirst/ifslastp leak, 2010-09-08).  It was found with the following
test case, based on the configure script for Tracker:

	dash -x -c '
		<<-_ACEOF
		$@
		_ACEOF
		exec
	' - abcdefgh
	+
	+ exec   �a
	exec: 1: : Permission denied

The missing ifsfree call is in expandarg when it returns to openhere
during here document expansion.

Reported-by: Aurelien Jarno <aurel32@debian.org>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
Hi,

Aurelien Jarno wrote[1]:

>   https://buildd.debian.org/fetch.cgi?pkg=tracker&arch=amd64&ver=0.10.3-1&stamp=1299968124&file=log&as=raw
[...]
> |  57145 dash     CALL  execve(0x806bf64,0x806ba64,0x806bef4)
> |  57145 dash     NAMI  "/usr/local/bincd$e,f4g<hDnLoTpu"

This patch seems to fix it.  Thoughts?

[1] http://bugs.debian.org/618023

 src/expand.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/src/expand.c b/src/expand.c
index 7a9b157..eac6c6d 100644
--- a/src/expand.c
+++ b/src/expand.c
@@ -194,6 +194,7 @@ expandarg(union node *arg, struct arglist *arglist, int flag)
 	p = _STPUTC('\0', expdest);
 	expdest = p - 1;
 	if (arglist == NULL) {
+		ifsfree();
 		return;			/* here document expanded */
 	}
 	p = grabstackstr(p);
-- 
1.7.4.1


       reply	other threads:[~2011-03-13 18:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20110313144103.30026.48296.reportbug@volta.aurel32.net>
2011-03-13 18:48 ` Jonathan Nieder [this message]
2011-03-15  8:02   ` [PATCH dash] [EXPAND] Free IFS state after here document expansion Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110313184858.GA6687@elie \
    --to=jrnieder@gmail.com \
    --cc=aurel32@debian.org \
    --cc=dash@vger.kernel.org \
    --cc=herbert@gondor.apana.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox