mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
Fix subshell file descriptor leak
A file descriptor (at least 3, can't reproduce for 4 and up) opened with 'exec' or 'redirect' in a virtual/non-forked subshell survived that subshell after exiting it: $ ksh -c '(redirect 3>&1); echo bug >&3' bug src/cmd/ksh93/sh/io.c: - Apply a patch from OpenSUSE (ksh93-redirectleak.dif). Source: https://build.opensuse.org/package/show/openSUSE:Leap:42.3:Update/ksh src/cmd/ksh93/tests/io.sh: - Add regression test. Thanks to Marc Wilson for flagging this up.
This commit is contained in:
parent
0c96f9749b
commit
db72f41f4b
3 changed files with 23 additions and 0 deletions
|
@ -1422,7 +1422,17 @@ int sh_redirect(Shell_t *shp,struct ionod *iop, int flag)
|
|||
sh_iosave(shp,fn,indx,tname?fname:(trunc?Empty:0));
|
||||
}
|
||||
else if(sh_subsavefd(fn))
|
||||
{
|
||||
if(fd==fn)
|
||||
{
|
||||
if((r=sh_fcntl(fd,F_DUPFD,10)) > 0)
|
||||
{
|
||||
fd = r;
|
||||
sh_close(fn);
|
||||
}
|
||||
}
|
||||
sh_iosave(shp,fn,indx|IOSUBSHELL,tname?fname:0);
|
||||
}
|
||||
}
|
||||
if(fd<0)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue