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 crash when 'kill %%' and 'kill %+' are run (#35)

Ksh was trying to use the 'pw' variable as a valid pointer even
when it was NULL. This is fixed by doing the error check for
'pw' before doing anything else in 'job_kill'.

This bugfix is from Red Hat:
44e0a643a9/f/SOURCES/ksh-20130214-fixkill.patch

Fixes #34
This commit is contained in:
Johnothan King 2020-06-22 10:11:19 -07:00 committed by Martijn Dekker
parent 3ba4900e9c
commit ff358f3464
4 changed files with 13 additions and 3 deletions

View file

@ -460,5 +460,12 @@ then [[ $actual == *Killed*Killed* ]] && msg='ksh killed itself' || msg='unexpec
fi
let "${actual##*$'\n'} > 128" || err_exit "child process signal did not cause exit status > 128"
# ======
# Killing a non-existent job shouldn't cause a segfault. Note that `2> /dev/null` has no effect when
# there is a segfault.
$SHELL -c 'kill %% 2> /dev/null'; [[ $? == 1 ]] || err_exit $'`kill` doesn\'t handle a non-existent job correctly when passed \'%%\''
$SHELL -c 'kill %+ 2> /dev/null'; [[ $? == 1 ]] || err_exit $'`kill` doesn\'t handle a non-existent job correctly when passed \'%+\''
$SHELL -c 'kill %- 2> /dev/null'; [[ $? == 1 ]] || err_exit $'`kill` doesn\'t handle a non-existent job correctly when passed \'%-\''
# ======
exit $((Errors<125?Errors:125))