7 Bug-Reported-by: Tim Waugh <twaugh@redhat.com>, Laird Breyer <laird@lbreyer.com>
8 Bug-Reference-ID: <20060105174434.GY16000@redhat.com>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2006-01/msg00009.html
10 http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=347695
14 When the number of saved jobs exceeds the initial size of the jobs array
15 (4096 slots), the array must be compacted and reallocated. An error in
16 the code to do that could cause a segmentation fault.
20 *** ../bash-3.1/jobs.c Fri Nov 11 23:13:27 2005
21 --- jobs.c Wed Feb 1 13:55:38 2006
29 nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
34 ! int nsize, i, j, ncur, nprev;
37 + ncur = nprev = NO_JOB;
38 nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
43 BLOCK_CHILD (set, oset);
44 ! nlist = (JOB **) xmalloc (nsize * sizeof (JOB *));
45 for (i = j = 0; i < js.j_jobslots; i++)
47 ! nlist[j++] = jobs[i];
50 ! js.j_lastj = (j > 0) ? j - 1: 0;
51 js.j_jobslots = nsize;
59 BLOCK_CHILD (set, oset);
60 ! nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *));
62 for (i = j = 0; i < js.j_jobslots; i++)
65 ! if (i == js.j_current)
67 ! if (i == js.j_previous)
69 ! nlist[j++] = jobs[i];
73 ! itrace ("realloc_jobs_list: resize jobs list from %d to %d", js.j_jobslots, nsize);
74 ! itrace ("realloc_jobs_list: j_lastj changed from %d to %d", js.j_lastj, (j > 0) ? j - 1 : 0);
75 ! itrace ("realloc_jobs_list: j_njobs changed from %d to %d", js.j_njobs, (j > 0) ? j - 1 : 0);
79 ! js.j_lastj = (j > 0) ? j - 1 : 0;
81 js.j_jobslots = nsize;
83 ! /* Zero out remaining slots in new jobs list */
84 ! for ( ; j < nsize; j++)
85 ! nlist[j] = (JOB *)NULL;
94 ! js.j_current = ncur;
95 ! if (nprev != NO_JOB)
96 ! js.j_previous = nprev;
98 ! /* Need to reset these */
99 ! if (js.j_current == NO_JOB || js.j_previous == NO_JOB || js.j_current > js.j_lastj || js.j_previous > js.j_lastj)
103 ! itrace ("realloc_jobs_list: reset js.j_current (%d) and js.j_previous (%d)", js.j_current, js.j_previous);
106 UNBLOCK_CHILD (oset);
107 *** ../bash-3.1/patchlevel.h Wed Jul 20 13:58:20 2005
108 --- patchlevel.h Wed Dec 7 13:48:42 2005
111 looks for to find the patch level (for the sccs version string). */
113 ! #define PATCHLEVEL 6
115 #endif /* _PATCHLEVEL_H_ */
117 looks for to find the patch level (for the sccs version string). */
119 ! #define PATCHLEVEL 7
121 #endif /* _PATCHLEVEL_H_ */