Bash-4.2 Official Patch 43

2013-03-10 Thread Chet Ramey
 BASH PATCH REPORT
 =

Bash-Release:   4.2
Patch-ID:   bash42-043

Bug-Reported-by:konsolebox 
Bug-Reference-ID:   

Bug-Reference-URL:  
http://lists.gnu.org/archive/html/bug-bash/2013-01/msg00138.html

Bug-Description:

When SIGCHLD is trapped, and a SIGCHLD trap handler runs when a pending
`read -t' invocation times out and generates SIGALRM, bash can crash with
a segmentation fault.

Patch (apply with `patch -p0'):

*** ../bash-4.2-patched/builtins/read.def   2012-10-31 21:22:51.000517000 
-0400
--- builtins/read.def   2013-01-25 10:28:16.38000 -0500
***
*** 386,393 
  /* Tricky.  The top of the unwind-protect stack is the free of
 input_string.  We want to run all the rest and use input_string,
!so we have to remove it from the stack. */
! remove_unwind_protect ();
! run_unwind_frame ("read_builtin");
  input_string[i] = '\0';   /* make sure it's terminated */
  retval = 128+SIGALRM;
  goto assign_vars;
--- 386,403 
  /* Tricky.  The top of the unwind-protect stack is the free of
 input_string.  We want to run all the rest and use input_string,
!so we have to save input_string temporarily, run the unwind-
!protects, then restore input_string so we can use it later. */
! 
  input_string[i] = '\0';   /* make sure it's terminated */
+ if (i == 0)
+   {
+ t = (char *)xmalloc (1);
+ t[0] = 0;
+   }
+ else
+   t = savestring (input_string);
+ 
+ run_unwind_frame ("read_builtin");
+ input_string = t;
  retval = 128+SIGALRM;
  goto assign_vars;

*** ../bash-4.2-patched/patchlevel.hSat Jun 12 20:14:48 2010
--- patchlevel.hThu Feb 24 21:41:34 2011
***
*** 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 42
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 43
  
  #endif /* _PATCHLEVEL_H_ */

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Bash-4.2 Official Patch 44

2013-03-10 Thread Chet Ramey
 BASH PATCH REPORT
 =

Bash-Release:   4.2
Patch-ID:   bash42-044

Bug-Reported-by:"Dashing" 
Bug-Reference-ID:   <20130211175049.d90786f...@smtp.hushmail.com>
Bug-Reference-URL:  
http://lists.gnu.org/archive/html/bug-bash/2013-02/msg00030.html

Bug-Description:

When converting a multibyte string to a wide character string as part of
pattern matching, bash does not handle the end of the string correctly,
causing the search for the NUL to go beyond the end of the string and
reference random memory.  Depending on the contents of that memory, bash
can produce errors or crash. 

Patch (apply with `patch -p0'):

*** ../bash-4.2-patched/lib/glob/xmbsrtowcs.c   2012-07-08 21:53:19.0 
-0400
--- lib/glob/xmbsrtowcs.c   2013-02-12 12:00:39.0 -0500
***
*** 217,220 
--- 217,226 
n = mbsnrtowcs(wsbuf+wcnum, &p, nms, wsbuf_size-wcnum, &state);
  
+   if (n == 0 && p == 0)
+   {
+ wsbuf[wcnum] = L'\0';
+ break;
+   }
+ 
/* Compensate for taking single byte on wcs conversion failure above. */
if (wcslength == 1 && (n == 0 || n == (size_t)-1))
***
*** 222,226 
  state = tmp_state;
  p = tmp_p;
! wsbuf[wcnum++] = *p++;
}
else
--- 228,238 
  state = tmp_state;
  p = tmp_p;
! wsbuf[wcnum] = *p;
! if (*p == 0)
!   break;
! else
!   {
! wcnum++; p++;
!   }
}
else

*** ../bash-4.2-patched/patchlevel.hSat Jun 12 20:14:48 2010
--- patchlevel.hThu Feb 24 21:41:34 2011
***
*** 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 43
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 44
  
  #endif /* _PATCHLEVEL_H_ */

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



Bash-4.2 Official Patch 45

2013-03-10 Thread Chet Ramey
 BASH PATCH REPORT
 =

Bash-Release:   4.2
Patch-ID:   bash42-045

Bug-Reported-by:Stephane Chazelas 
Bug-Reference-ID:   <20130218195539.ga9...@chaz.gmail.com>
Bug-Reference-URL:  
http://lists.gnu.org/archive/html/bug-bash/2013-02/msg00080.html

Bug-Description:

The <&n- and >&n- redirections, which move one file descriptor to another,
leave the file descriptor closed when applied to builtins or compound
commands.

Patch (apply with `patch -p0'):

*** ../bash-4.2-patched/redir.c 2013-01-30 11:56:09.0 -0500
--- redir.c 2013-02-19 09:38:36.0 -0500
***
*** 1008,1011 
--- 1008,1021 
  REDIRECTION_ERROR (r, errno, -1);
}
+ if ((flags & RX_UNDOABLE) && (ri == r_move_input || ri == 
r_move_output))
+   {
+ /* r_move_input and r_move_output add an additional close()
+that needs to be undone */
+ if (fcntl (redirector, F_GETFD, 0) != -1)
+   {
+ r = add_undo_redirect (redir_fd, r_close_this, -1);
+ REDIRECTION_ERROR (r, errno, -1);
+   }
+   }
  #if defined (BUFFERED_INPUT)
  check_bash_input (redirector);

*** ../bash-4.2-patched/patchlevel.hSat Jun 12 20:14:48 2010
--- patchlevel.hThu Feb 24 21:41:34 2011
***
*** 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 44
  
  #endif /* _PATCHLEVEL_H_ */
--- 26,30 
 looks for to find the patch level (for the sccs version string). */
  
! #define PATCHLEVEL 45
  
  #endif /* _PATCHLEVEL_H_ */

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/



show-all-if-ambiguous inserts spurious backslashes

2013-03-10 Thread Felix
If you have "set show-all-if-ambiguous on" in your .inputrc, typing
this sequence in bash (in a directory containing some non-hidden files):

echo *

Results in the list of possible matches being displayed (as expected),
but the command line is then edited to:

echo \*

Which is probably not what the user wanted.

~Felix.



Re: show-all-if-ambiguous inserts spurious backslashes

2013-03-10 Thread Chet Ramey
On 3/10/13 5:26 PM, Marcel (Felix) Giannelia wrote:
> If you have "set show-all-if-ambiguous on" in your .inputrc, typing
> this sequence in bash (in a directory containing some non-hidden files):
> 
> echo *
> 
> Results in the list of possible matches being displayed (as expected),
> but the command line is then edited to:
> 
> echo \*
> 
> Which is probably not what the user wanted.

Thanks for the report.  The bash default completion code needs to treat
TAB with show-all-if-ambigous on the same as straight TAB.  This will be
fixed in the next release.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRUc...@case.eduhttp://cnswww.cns.cwru.edu/~chet/