Roman Rakus 23098d
			     BASH PATCH REPORT
Roman Rakus 23098d
			     =================
Roman Rakus 23098d
Roman Rakus 23098d
Bash-Release:	4.2
Roman Rakus 23098d
Patch-ID:	bash42-009
Roman Rakus 23098d
Roman Rakus 23098d
Bug-Reported-by:	<piuma@piumalab.org>
Roman Rakus 23098d
Bug-Reference-ID:	<4DAAC0DB.7060606@piumalab.org>
Roman Rakus 23098d
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2011-04/msg00075.html
Roman Rakus 23098d
Roman Rakus 23098d
Bug-Description:
Roman Rakus 23098d
Roman Rakus 23098d
Under certain circumstances, running `fc -l' two times in succession with a
Roman Rakus 23098d
relative history offset at the end of the history will result in an incorrect
Roman Rakus 23098d
calculation of the last history entry and a seg fault.
Roman Rakus 23098d
Roman Rakus 23098d
Patch (apply with `patch -p0'):
Roman Rakus 23098d
Roman Rakus 23098d
*** ../bash-4.2-patched/builtins/fc.def	2010-05-30 18:25:38.000000000 -0400
Roman Rakus 23098d
--- builtins/fc.def	2011-04-19 15:46:17.000000000 -0400
Roman Rakus 23098d
***************
Roman Rakus 23098d
*** 305,309 ****
Roman Rakus 23098d
  
Roman Rakus 23098d
    /* XXX */
Roman Rakus 23098d
!   if (saved_command_line_count > 0 && i == last_hist && hlist[last_hist] == 0)
Roman Rakus 23098d
      while (last_hist >= 0 && hlist[last_hist] == 0)
Roman Rakus 23098d
        last_hist--;
Roman Rakus 23098d
--- 305,309 ----
Roman Rakus 23098d
  
Roman Rakus 23098d
    /* XXX */
Roman Rakus 23098d
!   if (i == last_hist && hlist[last_hist] == 0)
Roman Rakus 23098d
      while (last_hist >= 0 && hlist[last_hist] == 0)
Roman Rakus 23098d
        last_hist--;
Roman Rakus 23098d
***************
Roman Rakus 23098d
*** 476,480 ****
Roman Rakus 23098d
  {
Roman Rakus 23098d
    int sign, n, clen, rh;
Roman Rakus 23098d
!   register int i, j;
Roman Rakus 23098d
    register char *s;
Roman Rakus 23098d
  
Roman Rakus 23098d
--- 476,480 ----
Roman Rakus 23098d
  {
Roman Rakus 23098d
    int sign, n, clen, rh;
Roman Rakus 23098d
!   register int i, j, last_hist;
Roman Rakus 23098d
    register char *s;
Roman Rakus 23098d
  
Roman Rakus 23098d
***************
Roman Rakus 23098d
*** 496,500 ****
Roman Rakus 23098d
       calculation as if it were on. */
Roman Rakus 23098d
    rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
Roman Rakus 23098d
!   i -= rh + hist_last_line_added;
Roman Rakus 23098d
  
Roman Rakus 23098d
    /* No specification defaults to most recent command. */
Roman Rakus 23098d
--- 496,508 ----
Roman Rakus 23098d
       calculation as if it were on. */
Roman Rakus 23098d
    rh = remember_on_history || ((subshell_environment & SUBSHELL_COMSUB) && enable_history_list);
Roman Rakus 23098d
!   last_hist = i - rh - hist_last_line_added;
Roman Rakus 23098d
! 
Roman Rakus 23098d
!   if (i == last_hist && hlist[last_hist] == 0)
Roman Rakus 23098d
!     while (last_hist >= 0 && hlist[last_hist] == 0)
Roman Rakus 23098d
!       last_hist--;
Roman Rakus 23098d
!   if (last_hist < 0)
Roman Rakus 23098d
!     return (-1);
Roman Rakus 23098d
! 
Roman Rakus 23098d
!   i = last_hist;
Roman Rakus 23098d
  
Roman Rakus 23098d
    /* No specification defaults to most recent command. */
Roman Rakus 23098d
*** ../bash-4.2-patched/patchlevel.h	Sat Jun 12 20:14:48 2010
Roman Rakus 23098d
--- patchlevel.h	Thu Feb 24 21:41:34 2011
Roman Rakus 23098d
***************
Roman Rakus 23098d
*** 26,30 ****
Roman Rakus 23098d
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 23098d
  
Roman Rakus 23098d
! #define PATCHLEVEL 8
Roman Rakus 23098d
  
Roman Rakus 23098d
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus 23098d
--- 26,30 ----
Roman Rakus 23098d
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 23098d
  
Roman Rakus 23098d
! #define PATCHLEVEL 9
Roman Rakus 23098d
  
Roman Rakus 23098d
  #endif /* _PATCHLEVEL_H_ */