fix: IFS manipulation in a function can cause crash

This commit is contained in:
Michal Hlavinka 2011-08-03 16:06:28 +02:00
parent 85f580bd4c
commit 09c4040fcc
2 changed files with 31 additions and 1 deletions

23
ksh-20110630-ifsfix.patch Normal file
View File

@ -0,0 +1,23 @@
diff -up ksh-20110630/src/cmd/ksh93/sh/subshell.c.ifsfix ksh-20110630/src/cmd/ksh93/sh/subshell.c
--- ksh-20110630/src/cmd/ksh93/sh/subshell.c.ifsfix 2011-06-09 15:16:19.000000000 +0200
+++ ksh-20110630/src/cmd/ksh93/sh/subshell.c 2011-08-03 07:58:55.749400810 +0200
@@ -304,7 +304,7 @@ static void nv_restore(struct subshell *
register Namval_t *mp, *np;
const char *save = sp->shpwd;
Namval_t *mpnext;
- int flags;
+ int flags,nofree;
sp->shpwd = 0; /* make sure sh_assignok doesn't save with nv_unset() */
for(lp=sp->svar; lp; lp=lq)
{
@@ -327,7 +327,9 @@ static void nv_restore(struct subshell *
nv_setsize(mp,nv_size(np));
if(!(flags&NV_MINIMAL))
mp->nvenv = np->nvenv;
- mp->nvfun = np->nvfun;
+ nofree = mp->nvfun?mp->nvfun->nofree:0;
+ if((mp->nvfun = np->nvfun) && nofree)
+ mp->nvfun->nofree = nofree;
if(nv_isattr(np,NV_IDENT))
{
nv_offattr(np,NV_IDENT);

View File

@ -6,7 +6,7 @@ URL: http://www.kornshell.com/
Group: System Environment/Shells
License: CPL
Version: 20110630
Release: 1%{?dist}
Release: 2%{?dist}
Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{releasedate}.tgz
Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{releasedate}.tgz
Source3: kshrc.rhs
@ -20,6 +20,9 @@ Patch1: ksh-20070328-builtins.patch
#fix regression test suite to be usable during packagebuild - Fedora/RHEL specific
Patch2: ksh-20100826-fixregr.patch
# for ksh < 2011-08-03
Patch3: ksh-2011063-ifsfix.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Conflicts: pdksh
Requires: coreutils, glibc-common, diffutils
@ -40,6 +43,7 @@ with "sh" (the Bourne Shell).
%setup -q -T -D -a 1
%patch1 -p1 -b .builtins
%patch2 -p1 -b .fixregr
%patch3 -p1 -b .ifsfix
#/dev/fd test does not work because of mock
sed -i 's|ls /dev/fd|ls /proc/self/fd|' src/cmd/ksh93/features/options
@ -120,6 +124,9 @@ fi
rm -rf $RPM_BUILD_ROOT
%changelog
* Wed Aug 03 2011 Michal Hlavinka <mhlavink@redhat.com> - 20110630-2
- fix: IFS manipulation in a function can cause crash
* Fri Jul 01 2011 Michal Hlavinka <mhlavink@redhat.com> - 20110630-1
- ksh updated to 2011-06-30