bash31-007 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 3.1
  4. Patch-ID: bash31-007
  5. Bug-Reported-by: Tim Waugh <twaugh@redhat.com>, Laird Breyer <laird@lbreyer.com>
  6. Bug-Reference-ID: <20060105174434.GY16000@redhat.com>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2006-01/msg00009.html
  8. http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=347695
  9. Bug-Description:
  10. When the number of saved jobs exceeds the initial size of the jobs array
  11. (4096 slots), the array must be compacted and reallocated. An error in
  12. the code to do that could cause a segmentation fault.
  13. Patch:
  14. *** bash-3.1/jobs.c Fri Nov 11 23:13:27 2005
  15. --- bash-3.1/jobs.c Wed Feb 1 13:55:38 2006
  16. ***************
  17. *** 845,851 ****
  18. {
  19. sigset_t set, oset;
  20. ! int nsize, i, j;
  21. JOB **nlist;
  22. nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
  23. nsize *= JOB_SLOTS;
  24. --- 888,895 ----
  25. {
  26. sigset_t set, oset;
  27. ! int nsize, i, j, ncur, nprev;
  28. JOB **nlist;
  29. + ncur = nprev = NO_JOB;
  30. nsize = ((js.j_njobs + JOB_SLOTS - 1) / JOB_SLOTS);
  31. nsize *= JOB_SLOTS;
  32. ***************
  33. *** 855,869 ****
  34. BLOCK_CHILD (set, oset);
  35. ! nlist = (JOB **) xmalloc (nsize * sizeof (JOB *));
  36. for (i = j = 0; i < js.j_jobslots; i++)
  37. if (jobs[i])
  38. ! nlist[j++] = jobs[i];
  39. js.j_firstj = 0;
  40. ! js.j_lastj = (j > 0) ? j - 1: 0;
  41. js.j_jobslots = nsize;
  42. ! free (jobs);
  43. ! jobs = nlist;
  44. UNBLOCK_CHILD (oset);
  45. --- 899,947 ----
  46. BLOCK_CHILD (set, oset);
  47. ! nlist = (js.j_jobslots == nsize) ? jobs : (JOB **) xmalloc (nsize * sizeof (JOB *));
  48. !
  49. for (i = j = 0; i < js.j_jobslots; i++)
  50. if (jobs[i])
  51. ! {
  52. ! if (i == js.j_current)
  53. ! ncur = j;
  54. ! if (i == js.j_previous)
  55. ! nprev = j;
  56. ! nlist[j++] = jobs[i];
  57. ! }
  58. !
  59. ! #if defined (DEBUG)
  60. ! itrace ("realloc_jobs_list: resize jobs list from %d to %d", js.j_jobslots, nsize);
  61. ! itrace ("realloc_jobs_list: j_lastj changed from %d to %d", js.j_lastj, (j > 0) ? j - 1 : 0);
  62. ! itrace ("realloc_jobs_list: j_njobs changed from %d to %d", js.j_njobs, (j > 0) ? j - 1 : 0);
  63. ! #endif
  64. js.j_firstj = 0;
  65. ! js.j_lastj = (j > 0) ? j - 1 : 0;
  66. ! js.j_njobs = j;
  67. js.j_jobslots = nsize;
  68. ! /* Zero out remaining slots in new jobs list */
  69. ! for ( ; j < nsize; j++)
  70. ! nlist[j] = (JOB *)NULL;
  71. !
  72. ! if (jobs != nlist)
  73. ! {
  74. ! free (jobs);
  75. ! jobs = nlist;
  76. ! }
  77. !
  78. ! if (ncur != NO_JOB)
  79. ! js.j_current = ncur;
  80. ! if (nprev != NO_JOB)
  81. ! js.j_previous = nprev;
  82. !
  83. ! /* Need to reset these */
  84. ! if (js.j_current == NO_JOB || js.j_previous == NO_JOB || js.j_current > js.j_lastj || js.j_previous > js.j_lastj)
  85. ! reset_current ();
  86. !
  87. ! #ifdef DEBUG
  88. ! itrace ("realloc_jobs_list: reset js.j_current (%d) and js.j_previous (%d)", js.j_current, js.j_previous);
  89. ! #endif
  90. UNBLOCK_CHILD (oset);
  91. *** bash-3.1/patchlevel.h Wed Jul 20 13:58:20 2005
  92. --- bash-3.1/patchlevel.h Wed Dec 7 13:48:42 2005
  93. ***************
  94. *** 26,30 ****
  95. looks for to find the patch level (for the sccs version string). */
  96. ! #define PATCHLEVEL 6
  97. #endif /* _PATCHLEVEL_H_ */
  98. --- 26,30 ----
  99. looks for to find the patch level (for the sccs version string). */
  100. ! #define PATCHLEVEL 7
  101. #endif /* _PATCHLEVEL_H_ */