mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
The >&- redirection subshell leak fixed in6304dfce
still existed for shared-state ${ command substitutions; } a.k.a. subshares, which cannot be forked. I previously noticed that sh_subsavefd() saves the FD state even for subshares. That seems logically incorrect as subshares share their state with the invoking environment by definition. src/cmd/ksh93/sh/subshell.c: sh_subsavefd(): - Sure enough, adding a check for !sh.subshare fixes the bug. - Use the sh.subshell counter and not the subshell data pointer to check for a virtual subshell. If the shell is reinitialised in a fork to execute a new script (see 0af81992), any parent virtual subshell data is currently not cleared as it is locally scoped to subshell.c, so that check would be incorrect then. src/cmd/ksh93/sh/io.c: sh_redirect: - Remove now-redundant (and actually incorrectly placed) check for sh.subshare added infb755163
.
This commit is contained in:
parent
6304dfce41
commit
1cdd963f53
3 changed files with 9 additions and 2 deletions
|
@ -1468,7 +1468,7 @@ int sh_redirect(struct ionod *iop, int flag)
|
|||
}
|
||||
else if(sh_subsavefd(fn))
|
||||
{
|
||||
if(fd==fn && !sh.subshare)
|
||||
if(fd==fn)
|
||||
{
|
||||
if((r=sh_fcntl(fd,F_DUPFD,10)) > 0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue