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

Fix a fork bomb when vi is run from a script and sent Ctrl-Z (#73)

This bug was reported on the old mailing list:
https://www.mail-archive.com/ast-developers@lists.research.att.com/msg00207.html

A fork bomb can occur when SIGTSTP is sent to the vi editor. Vi
must be launched from a script run with exec (tested with
BusyBox vi, nvi and vim):
$ cat /tmp/foo
vi /tmp/bar
echo end
$ ksh
$ chmod +x /tmp/foo
$ exec /tmp/foo
While in vi, send SIGTSTP using Ctrl-Z

src/cmd/ksh93/sh/fault.c:
- Only fork after Ctrl-Z if job control is available. The patch
  used checks 'job.jobcontrol' instead of 'SH_MONITOR':
  https://git.centos.org/rpms/ksh/blob/c8/f/SOURCES/ksh-20120801-forkbomb.patch
This commit is contained in:
Johnothan King 2020-07-13 11:10:23 -07:00 committed by GitHub
parent 84e2f6d92f
commit 66c955bc8f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 2 deletions

View file

@ -519,7 +519,7 @@ void sh_exit(register int xno)
if(pp && pp->mode>1)
cursig = -1;
#ifdef SIGTSTP
if(shp->trapnote&SH_SIGTSTP)
if((shp->trapnote&SH_SIGTSTP) && job.jobcontrol)
{
/* ^Z detected by the shell */
shp->trapnote = 0;