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>
This commit is contained in:
parent
9db74e49e5
commit
493b9cae80
@ -10125,6 +10125,9 @@ popfile(void)
|
|||||||
{
|
{
|
||||||
struct parsefile *pf = g_parsefile;
|
struct parsefile *pf = g_parsefile;
|
||||||
|
|
||||||
|
if (pf == &basepf)
|
||||||
|
return;
|
||||||
|
|
||||||
INT_OFF;
|
INT_OFF;
|
||||||
if (pf->pf_fd >= 0)
|
if (pf->pf_fd >= 0)
|
||||||
close(pf->pf_fd);
|
close(pf->pf_fd);
|
||||||
@ -12286,7 +12289,7 @@ expandstr(const char *ps)
|
|||||||
static int
|
static int
|
||||||
evalstring(char *s, int flags)
|
evalstring(char *s, int flags)
|
||||||
{
|
{
|
||||||
struct jmploc *volatile savehandler = exception_handler;
|
struct jmploc *volatile savehandler;
|
||||||
struct jmploc jmploc;
|
struct jmploc jmploc;
|
||||||
int ex;
|
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.
|
* But if we skip popfile(), we hit EOF in eval's string, and exit.
|
||||||
*/
|
*/
|
||||||
savehandler = exception_handler;
|
savehandler = exception_handler;
|
||||||
exception_handler = &jmploc;
|
|
||||||
ex = setjmp(jmploc.loc);
|
ex = setjmp(jmploc.loc);
|
||||||
if (ex)
|
if (ex)
|
||||||
goto out;
|
goto out;
|
||||||
|
exception_handler = &jmploc;
|
||||||
|
|
||||||
while ((n = parsecmd(0)) != NODE_EOF) {
|
while ((n = parsecmd(0)) != NODE_EOF) {
|
||||||
int i;
|
int i;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user