1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-03-09 15:50:02 +00:00

Fix restoring DEBUG trap upon exiting virtual subshell

This trap failed to be restored correctly when being trapped in
a subshell, causing corruption or a crash when restoring the
parent shell environment's trap upon leaving the subshell.

Thanks to Koichi Nakashima for the report and reproducer.

src/cmd/ksh93/sh/fault.c: sh_sigreset():
- Fix an off-by-one error in the loop that restores the
  pseudosignal traps.

src/cmd/ksh93/tests/basic.sh:
- Test overwriting the main shell trap in a subshell for all
  pseudosignals.

Makes progress on: https://github.com/ksh93/ksh/issues/155
This commit is contained in:
Martijn Dekker 2021-01-24 00:49:36 +00:00
parent ac8e702ef2
commit 2a835a2d8a
4 changed files with 23 additions and 2 deletions

View file

@ -344,7 +344,7 @@ void sh_sigreset(register int mode)
sh.sigflag[sig] = flag;
}
}
for(sig=SH_DEBUGTRAP-1;sig>=0;sig--)
for(sig=SH_DEBUGTRAP; sig>=0; sig--)
{
if(trap=sh.st.trap[sig])
{