22461939 ksh93 20120801 version core dumps with Asian characters input
22550551 ksh dumps core in tc_ibtools testsuite run during OFUV testing
22561374 export in a subshell visible in another subshell
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ksh93/patches/240-22461939.patch Wed Mar 16 03:43:00 2016 -0700
@@ -0,0 +1,48 @@
+This fix has been developed inhouse. Patch has been submitted upstream but
+has not been accepted yet. The details can be found at
+https://github.com/att/ast/issues/6
+--- INIT.2012-08-01.old/src/cmd/ksh93/edit/emacs.c 2016-01-18 03:52:58.380801240 -0800
++++ INIT.2012-08-01/src/cmd/ksh93/edit/emacs.c 2016-02-05 01:39:08.350312914 -0800
[email protected]@ -90,6 +90,7 @@
+ static int print(int);
+ static int _isword(int);
+ # define isword(c) _isword(out[c])
++# define digit(c) ((c&~STRIP)==0 && isdigit(c))
+
+ #else
+ # define gencpy(a,b) strcpy((char*)(a),(char*)(b))
[email protected]@ -97,6 +98,7 @@
+ # define genlen(str) strlen(str)
+ # define print(c) isprint(c)
+ # define isword(c) (isalnum(out[c]) || (out[c]=='_'))
++# define digit(c) isdigit(c)
+ #endif /*SHOPT_MULTIBYTE */
+
+ typedef struct _emacs_
[email protected]@ -317,7 +319,7 @@
+ count = 1;
+ adjust = -1;
+ i = cur;
+- if(c!='\t' && c!=ESC && !isdigit(c))
++ if(c!='\t' && c!=ESC && !digit(c))
+ ep->ed->e_tabcount = 0;
+ switch(c)
+ {
[email protected]@ -775,7 +777,7 @@
+ int digit,ch;
+ digit = 0;
+ value = 0;
+- while ((i=ed_getchar(ep->ed,0)),isdigit(i))
++ while ((i=ed_getchar(ep->ed,0)),digit(i))
+ {
+ value *= 10;
+ value += (i - '0');
[email protected]@ -1013,7 +1015,7 @@
+ {
+ i=ed_getchar(ep->ed,0);
+ ed_ungetchar(ep->ed,i);
+- if(isdigit(i))
++ if(digit(i))
+ ed_ungetchar(ep->ed,ESC);
+ }
+ }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ksh93/patches/245-22550551.patch Wed Mar 16 03:43:00 2016 -0700
@@ -0,0 +1,120 @@
+This issue has been fixed upstream in the 2016-01-10-beta version.
+--- INIT.2012-08-01.old/src/cmd/ksh93/sh/jobs.c 2015-10-30 05:05:17.556367591 -0700
++++ INIT.2012-08-01.new/src/cmd/ksh93/sh/jobs.c 2016-02-23 04:23:52.229101513 -0800
[email protected]@ -58,6 +58,7 @@
+ struct jobsave *next;
+ pid_t pid;
+ unsigned short exitval;
++ unsigned short env;
+ };
+
+ static struct jobsave *job_savelist;
[email protected]@ -133,7 +134,7 @@
+ #define P_BG 01000
+ #endif /* SHOPT_BGX */
+
+-static int job_chksave(pid_t);
++static int job_chksave(pid_t,long);
+ static struct process *job_bypid(pid_t);
+ static struct process *job_byjid(int);
+ static char *job_sigmsg(int);
[email protected]@ -233,9 +234,9 @@
+ static struct jobsave *jobsave_create(pid_t pid)
+ {
+ register struct jobsave *jp = job_savelist;
+- job_chksave(pid);
++ job_chksave(pid,-1);
+ if(++bck.count > shgd->lim.child_max)
+- job_chksave(0);
++ job_chksave(0,-1);
+ if(jp)
+ {
+ njob_savelist--;
[email protected]@ -425,7 +426,7 @@
+ if(pid<=0)
+ break;
+ if(wstat==0)
+- job_chksave(pid);
++ job_chksave(pid,-1);
+ flags |= WNOHANG;
+ job.waitsafe++;
+ jp = 0;
[email protected]@ -1393,7 +1394,7 @@
+ else
+ pw->p_name = -1;
+ #endif /* JOBS */
+- if ((val = job_chksave(pid))>=0 && !jobfork)
++ if ((val = job_chksave(pid,pw->p_env))>=0 && !jobfork)
+ {
+ pw->p_exit = val;
+ if(pw->p_exit==SH_STOPSIG)
[email protected]@ -1515,7 +1516,7 @@
+ if(!(pw=job_bypid(pid)))
+ {
+ /* check to see whether job status has been saved */
+- if((shp->exitval = job_chksave(pid)) < 0)
++ if((shp->exitval = job_chksave(pid,shp->curenv)) < 0)
+ shp->exitval = ERROR_NOENT;
+ exitset();
+ job_unlock();
[email protected]@ -1937,7 +1938,7 @@
+ * if pid==0, then oldest saved process is deleted
+ * If pid is not found a -1 is returned.
+ */
+-static int job_chksave(register pid_t pid)
++static int job_chksave(register pid_t pid, long env)
+ {
+ register struct jobsave *jp = bck.list, *jpold=0;
+ register int r= -1;
[email protected]@ -1957,9 +1958,10 @@
+ {
+ count = bp->count;
+ jp = bp->list;
++ jpold = 0;
+ goto again;
+ }
+- if(jp)
++ if(jp && (env<0 || jp->env==env))
+ {
+ r = 0;
+ if(pid)
[email protected]@ -1996,15 +1998,18 @@
+
+ void job_subrestore(void* ptr)
+ {
+- register struct jobsave *jp;
++ register struct jobsave *jp,*jpnext;
+ register struct back_save *bp = (struct back_save*)ptr;
+ register struct process *pw, *px, *pwnext;
+ struct jobsave *end=NULL;
++ int i=0;
+ job_lock();
+- for(jp=bck.list; jp; jp=jp->next)
++ for(jp=bck.list; jp; jp=jpnext,i++)
+ {
+- if (!jp->next)
++ if (!(jpnext=jp->next) || jp==jpnext)
+ end = jp;
++ if(i>=shgd->lim.child_max)
++ break;
+ }
+ if(end)
+ end->next = bp->list;
[email protected]@ -2013,7 +2018,7 @@
+ bck.count += bp->count;
+ bck.prev = bp->prev;
+ while(bck.count > shgd->lim.child_max)
+- job_chksave(0);
++ job_chksave(0,-1);
+ for(pw=job.pwlist; pw; pw=pwnext)
+ {
+ pwnext = pw->p_nxtjob;
[email protected]@ -2051,7 +2056,7 @@
+ job.in_critical = 0;
+ break;
+ default:
+- job_chksave(parent);
++ job_chksave(parent,-1);
+ jobfork=0;
+ job_unlock();
+ break;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/components/ksh93/patches/250-22561374.patch Wed Mar 16 03:43:00 2016 -0700
@@ -0,0 +1,15 @@
+This fix has been developed inhouse. Patch has been submitted upstream but
+has not been accepted yet. The details can be found at
+https://github.com/att/ast/issues/7
+--- INIT.2012-08-01.old/src/cmd/ksh93/sh/subshell.c 2016-03-01 04:01:06.513890578 -0800
++++ INIT.2012-08-01/src/cmd/ksh93/shsubshell.c 2016-03-01 04:02:43.617872391 -0800
[email protected]@ -260,9 +260,6 @@
+ shp = sp->shp;
+ dp = shp->var_tree;
+
+- /* don't bother to save if in newer scope */
+- if(sp->var!=shp->var_tree && sp->var!=shp->var_base && shp->last_root==shp->var_tree)
+- return(np);
+ if((ap=nv_arrayptr(np)) && (mp=nv_opensub(np)))
+ {
+ shp->last_root = ap->table;