1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-15 04:32:24 +00:00

alarm: don't save sh.ifstable (re: 18b3f4aa)

It is not correct to save sh.ifstable (a.k.a. shp->ifstable) before
calling a function and then restore it after; this can cause field
splitting to malfunction. See 70368c57.

The change to init.c in the Red Hat patch applied in 18b3f4aa
(shp->ifstable[0] = S_EOF) appears to be sufficient.

src/cmd/ksh93/bltins/alarm.c:
- Revert save/restore of sh.ifstable.

src/cmd/ksh93/tests/builtins.sh:
- Tweak the regression test to work correctly on a slower machine,
  i.e. a Raspberry Pi running FreeBSD 12.2 arm64 (thanks to hyenias
  for providing testing access).
This commit is contained in:
Martijn Dekker 2021-01-26 15:48:38 +00:00
parent e72543a9fa
commit f033bb0351
2 changed files with 2 additions and 9 deletions

View file

@ -34,8 +34,6 @@
* > happen is that the trap is marked for execution (sh_trapnote) and run after * > happen is that the trap is marked for execution (sh_trapnote) and run after
* > the current command completes. The time trap should wake up the shell if * > the current command completes. The time trap should wake up the shell if
* > it is blocked and it should return and then handle the trap. * > it is blocked and it should return and then handle the trap.
*
* When that is done, the save_ifstable workaround can probably be removed.
*/ */
#include "defs.h" #include "defs.h"
@ -153,12 +151,7 @@ void sh_timetraps(Shell_t *shp)
{ {
tp->flags &= ~L_FLAG; tp->flags &= ~L_FLAG;
if(tp->action) if(tp->action)
{
char save_ifstable[256];
memcpy(save_ifstable,shp->ifstable,sizeof(save_ifstable));
sh_fun(tp->action,tp->node,(char**)0); sh_fun(tp->action,tp->node,(char**)0);
memcpy(shp->ifstable,save_ifstable,sizeof(save_ifstable));
}
tp->flags &= ~L_FLAG; tp->flags &= ~L_FLAG;
if(!tp->flags) if(!tp->flags)
{ {

View file

@ -996,11 +996,11 @@ done 3< <(builtin)
if (builtin alarm) 2>/dev/null if (builtin alarm) 2>/dev/null
then got=$( { "$SHELL" -c ' then got=$( { "$SHELL" -c '
builtin alarm builtin alarm
alarm -r alarm_handler +.001 alarm -r alarm_handler +.005
i=0 i=0
function alarm_handler.alarm function alarm_handler.alarm
{ {
let "(++i) > 100" && exit let "(++i) > 20" && exit
} }
while :; do while :; do
echo cargo,odds and ends,jetsam,junk,wreckage,castoffs,sea-drift echo cargo,odds and ends,jetsam,junk,wreckage,castoffs,sea-drift