mirror of
git://git.code.sf.net/p/cdesktopenv/code
synced 2025-03-09 15:50:02 +00:00
combining alarm and IFS caused segfault (rhbz#1176670)
The undocumented alarm builtin executes actions unsafely so that 'read' with an IFS assignment crashed when an alarm was triggered. This applies an edited version of a Red Hat patch:642af4d6/f/ksh-20120801-alarmifs.patch
Prior discussion: https://bugzilla.redhat.com/1176670 src/cmd/ksh93/bltins/alarm.c: - Add a TODO note based on dgk's 2014 email cited in the RH bug. - When executing the trap function, save and restore the IFS table. src/cmd/ksh93/sh/init.c: get_ifs(): - Remove now-unnecessary SHOPT_MULTIBYTE preprocessor directives as8477d2ce
lets the compiler optimise out multibyte code if needed. - Initialise the 0 position of the IFS table to S_EOF. This corresponds with the static state tables in data/lexstates.c. src/cmd/ksh93/tests/builtins.sh: - Crash test.
This commit is contained in:
parent
f7c3565f4e
commit
18b3f4aa28
3 changed files with 41 additions and 8 deletions
|
@ -503,21 +503,14 @@ static char* get_ifs(register Namval_t* np, Namfun_t *fp)
|
|||
memset(shp->ifstable,0,(1<<CHAR_BIT));
|
||||
if(cp=value)
|
||||
{
|
||||
#if SHOPT_MULTIBYTE
|
||||
while(n=mbsize(cp),c= *(unsigned char*)cp)
|
||||
#else
|
||||
while(c= *(unsigned char*)cp++)
|
||||
#endif /* SHOPT_MULTIBYTE */
|
||||
while(n = mbsize(cp), c = *(unsigned char*)cp++)
|
||||
{
|
||||
#if SHOPT_MULTIBYTE
|
||||
cp++;
|
||||
if(n>1)
|
||||
{
|
||||
cp += (n-1);
|
||||
shp->ifstable[c] = S_MBYTE;
|
||||
continue;
|
||||
}
|
||||
#endif /* SHOPT_MULTIBYTE */
|
||||
n = S_DELIM;
|
||||
if(c== *cp)
|
||||
cp++;
|
||||
|
@ -533,6 +526,7 @@ static char* get_ifs(register Namval_t* np, Namfun_t *fp)
|
|||
shp->ifstable[' '] = shp->ifstable['\t'] = S_SPACE;
|
||||
shp->ifstable['\n'] = S_NL;
|
||||
}
|
||||
shp->ifstable[0] = S_EOF;
|
||||
}
|
||||
return(value);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue