summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2016-10-30 18:27:14 +0100
committerDenys Vlasenko2016-10-30 18:27:14 +0100
commit493b9cae808093ff5d89b5fb794e3991859e7df6 (patch)
tree05b59197059c377c39dbacef3cc7238843e080ca
parent9db74e49e5b462089c6eec0182d819c0d4708e57 (diff)
downloadbusybox-493b9cae808093ff5d89b5fb794e3991859e7df6.zip
busybox-493b9cae808093ff5d89b5fb794e3991859e7df6.tar.gz
ash: make popfile() anfter popallfiles() safe
In this example: ash -c 'readonly x; echo $(command eval x=2)' evalstring() is called after forkchild(), which calls popallfiles(). On exception, evalstring() will popfile(). Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--shell/ash.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/shell/ash.c b/shell/ash.c
index fc1b5d9..0c84805 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -10125,6 +10125,9 @@ popfile(void)
{
struct parsefile *pf = g_parsefile;
+ if (pf == &basepf)
+ return;
+
INT_OFF;
if (pf->pf_fd >= 0)
close(pf->pf_fd);
@@ -12286,7 +12289,7 @@ expandstr(const char *ps)
static int
evalstring(char *s, int flags)
{
- struct jmploc *volatile savehandler = exception_handler;
+ struct jmploc *volatile savehandler;
struct jmploc jmploc;
int ex;
@@ -12307,10 +12310,10 @@ evalstring(char *s, int flags)
* But if we skip popfile(), we hit EOF in eval's string, and exit.
*/
savehandler = exception_handler;
- exception_handler = &jmploc;
ex = setjmp(jmploc.loc);
if (ex)
goto out;
+ exception_handler = &jmploc;
while ((n = parsecmd(0)) != NODE_EOF) {
int i;