ksh hangs when command substitution containing a pipe fills out the pipe buffer (#1121204)

This commit is contained in:
Michal Hlavinka 2015-02-27 12:43:58 +01:00
parent 5b24864bf9
commit d679af8dc6
2 changed files with 23 additions and 9 deletions

View File

@ -1,8 +1,7 @@
diff -up ksh-20140415/src/cmd/ksh93/sh/subshell.c.hokaido ksh-20140415/src/cmd/ksh93/sh/subshell.c diff -up ksh-20120801/src/cmd/ksh93/sh/xec.c.hokaido ksh-20120801/src/cmd/ksh93/sh/xec.c
diff -up ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido ksh-20140415/src/cmd/ksh93/sh/xec.c --- ksh-20120801/src/cmd/ksh93/sh/xec.c.hokaido 2014-09-18 14:41:57.696756230 +0200
--- ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido 2014-03-17 22:13:55.000000000 +0100 +++ ksh-20120801/src/cmd/ksh93/sh/xec.c 2014-09-18 14:43:55.439205247 +0200
+++ ksh-20140415/src/cmd/ksh93/sh/xec.c 2014-05-20 18:23:49.712532290 +0200 @@ -1633,12 +1633,20 @@ int sh_exec(register const Shnode_t *t,
@@ -1630,12 +1630,20 @@ tryagain:
#endif /* SHOPT_COSHELL */ #endif /* SHOPT_COSHELL */
if(shp->subshell) if(shp->subshell)
{ {
@ -11,7 +10,7 @@ diff -up ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido ksh-20140415/src/cmd/ksh93/
+ shp->comsub = 2; + shp->comsub = 2;
sh_subtmpfile(shp); sh_subtmpfile(shp);
+ shp->comsub = comsubsave; + shp->comsub = comsubsave;
+ if(shp->comsub==1 && !(shp->fdstatus[1]&IONOSEEK)) + if(shp->comsub==1 && (!(shp->fdstatus[1]&IONOSEEK)))
+ unpipe = iousepipe(shp); + unpipe = iousepipe(shp);
+ +
if((type&(FAMP|TFORK))==(FAMP|TFORK)) if((type&(FAMP|TFORK))==(FAMP|TFORK))
@ -24,3 +23,15 @@ diff -up ksh-20140415/src/cmd/ksh93/sh/xec.c.hokaido ksh-20140415/src/cmd/ksh93/
sh_subfork(); sh_subfork();
} }
} }
@@ -2107,7 +2115,11 @@ int sh_exec(register const Shnode_t *t,
job.curjobid = 0;
if(shp->subshell)
{
+ int comsubsave = shp->comsub;
+ if(comsubsave==1)
+ shp->comsub = 2;
sh_subtmpfile(shp);
+ shp->comsub = comsubsave;
if(shp->comsub==1 && !(shp->fdstatus[1]&IONOSEEK))
iousepipe(shp);
}

View File

@ -9,7 +9,7 @@ Group: System Environment/Shells
#CPL everywhere else (for KSH itself) #CPL everywhere else (for KSH itself)
License: CPL License: CPL
Version: %{releasedate} Version: %{releasedate}
Release: 21%{?dist} Release: 22%{?dist}
Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{release_date}.tgz Source0: http://www.research.att.com/~gsf/download/tgz/ast-ksh.%{release_date}.tgz
Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{release_date}.tgz Source1: http://www.research.att.com/~gsf/download/tgz/INIT.%{release_date}.tgz
Source2: kshcomp.conf Source2: kshcomp.conf
@ -118,7 +118,7 @@ Patch49: ksh-20120801-cdfix3.patch
# sent upstream, rhbz#1116506 # sent upstream, rhbz#1116506
Patch50: ksh-20120801-locking.patch Patch50: ksh-20120801-locking.patch
Patch100: ksh-20130613-cdfix4.patch Patch51: ksh-20130613-cdfix4.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
Conflicts: pdksh Conflicts: pdksh
@ -174,7 +174,7 @@ with "sh" (the Bourne Shell).
%patch48 -p1 -b .fununset %patch48 -p1 -b .fununset
%patch49 -p1 -b .cdfix3 %patch49 -p1 -b .cdfix3
%patch50 -p1 -b .locking %patch50 -p1 -b .locking
%patch100 -p1 -b .cdfix4 %patch51 -p1 -b .cdfix4
#/dev/fd test does not work because of mock #/dev/fd test does not work because of mock
sed -i 's|ls /dev/fd|ls /proc/self/fd|' src/cmd/ksh93/features/options sed -i 's|ls /dev/fd|ls /proc/self/fd|' src/cmd/ksh93/features/options
@ -275,6 +275,9 @@ fi
rm -rf $RPM_BUILD_ROOT rm -rf $RPM_BUILD_ROOT
%changelog %changelog
* Fri Feb 27 2015 Michal Hlavinka <mhlavink@redhat.com> - 20120801-22
- ksh hangs when command substitution containing a pipe fills out the pipe buffer (#1121204)
* Tue Aug 26 2014 Michal Hlavinka <mhlavink@redhat.com> - 20120801-21 * Tue Aug 26 2014 Michal Hlavinka <mhlavink@redhat.com> - 20120801-21
- cd builtin file descriptor operations messed with IO redirections (#1133586) - cd builtin file descriptor operations messed with IO redirections (#1133586)