bash-4.2-009.patch 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 4.2
  4. Patch-ID: bash42-009
  5. Bug-Reported-by: <piuma@piumalab.org>
  6. Bug-Reference-ID: <4DAAC0DB.7060606@piumalab.org>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2011-04/msg00075.html
  8. Bug-Description:
  9. Under certain circumstances, running `fc -l' two times in succession with a
  10. relative history offset at the end of the history will result in an incorrect
  11. calculation of the last history entry and a seg fault.
  12. Patch (apply with `patch -p0'):
  13. *** ../bash-4.2-patched/builtins/fc.def 2010-05-30 18:25:38.000000000 -0400
  14. --- ./builtins/fc.def 2011-04-19 15:46:17.000000000 -0400
  15. ***************
  16. *** 305,309 ****
  17. /* XXX */
  18. ! if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
  19. while (last_hist >= 0 && hlist[last_hist] == 0)
  20. last_hist--;
  21. --- 305,309 ----
  22. /* XXX */
  23. ! if (i == last_hist && hlist[last_hist] == 0)
  24. while (last_hist >= 0 && hlist[last_hist] == 0)
  25. last_hist--;
  26. ***************
  27. *** 476,480 ****
  28. {
  29. int sign, n, clen, rh;
  30. ! register int i, j;
  31. register char *s;
  32. --- 476,480 ----
  33. {
  34. int sign, n, clen, rh;
  35. ! register int i, j, last_hist;
  36. register char *s;
  37. ***************
  38. *** 496,500 ****
  39. calculation as if it were on. */
  40. rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
  41. ! i -= rh + hist_last_line_added;
  42. /* No specification defaults to most recent command. */
  43. --- 496,508 ----
  44. calculation as if it were on. */
  45. rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
  46. ! last_hist = i - rh - hist_last_line_added;
  47. !
  48. ! if (i == last_hist && hlist[last_hist] == 0)
  49. ! while (last_hist >= 0 && hlist[last_hist] == 0)
  50. ! last_hist--;
  51. ! if (last_hist < 0)
  52. ! return (-1);
  53. !
  54. ! i = last_hist;
  55. /* No specification defaults to most recent command. */
  56. *** ../bash-4.2-patched/patchlevel.h Sat Jun 12 20:14:48 2010
  57. --- ./patchlevel.h Thu Feb 24 21:41:34 2011
  58. ***************
  59. *** 26,30 ****
  60. looks for to find the patch level (for the sccs version string). */
  61. ! #define PATCHLEVEL 8
  62. #endif /* _PATCHLEVEL_H_ */
  63. --- 26,30 ----
  64. looks for to find the patch level (for the sccs version string). */
  65. ! #define PATCHLEVEL 9
  66. #endif /* _PATCHLEVEL_H_ */