Re: [PATCH] parser: Catch errors in expandstr

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

 



Herbert Xu wrote:
>This patch fixes it by using the literal value of PS1 should an
>error occur during expansion.

There's another case that should be handled.  PS1='`xxx(`' causes the
shell to exit because the old-style backquote leaves an additional file
on the stack.

Signed-off-by: Ron Yorston <rmy@xxxxxxxxx>
---
 src/parser.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/parser.c b/src/parser.c
index 201d5bd..d7e717a 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -1572,12 +1572,14 @@ const char *
 expandstr(const char *ps)
 {
 	struct jmploc *volatile savehandler;
+	struct parsefile *file_stop;
 	const char *volatile result;
 	volatile int saveprompt;
 	struct jmploc jmploc;
 	union node n;
 	int err;
 
+	file_stop = parsefile;
 	/* XXX Fix (char *) cast. */
 	setinputstring((char *)ps);
 
@@ -1605,7 +1607,7 @@ out:
 		longjmp(handler->loc, 1);
 
 	doprompt = saveprompt;
-	popfile();
+	unwindfiles(file_stop);
 
 	return result;
 }
-- 
2.24.1




[Index of Archives]     [LARTC]     [Bugtraq]     [Yosemite Forum]     [Photo]

  Powered by Linux