nalika / rpms / bash

Forked from rpms/bash 2 years ago
Clone
287226
			     BASH PATCH REPORT
287226
			     =================
287226
287226
Bash-Release:	4.2
287226
Patch-ID:	bash42-003
287226
287226
Bug-Reported-by:	Clark J. Wang <dearvoid@gmail.com>
287226
Bug-Reference-ID:	<AANLkTikZ_rVV-frR8Fh0PzhXnMKnm5XsUR-F3qtPPs5G@mail.gmail.com>
287226
Bug-Reference-URL:	http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00136.html
287226
287226
Bug-Description:
287226
287226
When using the pattern replacement and pattern removal word expansions, bash
287226
miscalculates the possible match length in the presence of an unescaped left
287226
bracket without a closing right bracket, resulting in a failure to match
287226
the pattern.
287226
287226
Patch (apply with `patch -p0'):
287226
287226
*** ../bash-4.2-patched/lib/glob/gmisc.c	2011-02-05 16:11:17.000000000 -0500
287226
--- lib/glob/gmisc.c	2011-02-18 23:53:42.000000000 -0500
287226
***************
287226
*** 78,83 ****
287226
       size_t wmax;
287226
  {
287226
!   wchar_t wc, *wbrack;
287226
!   int matlen, t, in_cclass, in_collsym, in_equiv;
287226
  
287226
    if (*wpat == 0)
287226
--- 78,83 ----
287226
       size_t wmax;
287226
  {
287226
!   wchar_t wc;
287226
!   int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
287226
  
287226
    if (*wpat == 0)
287226
***************
287226
*** 119,123 ****
287226
  	case L'[':
287226
  	  /* scan for ending `]', skipping over embedded [:...:] */
287226
! 	  wbrack = wpat;
287226
  	  wc = *wpat++;
287226
  	  do
287226
--- 119,123 ----
287226
  	case L'[':
287226
  	  /* scan for ending `]', skipping over embedded [:...:] */
287226
! 	  bracklen = 1;
287226
  	  wc = *wpat++;
287226
  	  do
287226
***************
287226
*** 125,140 ****
287226
  	      if (wc == 0)
287226
  		{
287226
! 	          matlen += wpat - wbrack - 1;	/* incremented below */
287226
! 	          break;
287226
  	        }
287226
  	      else if (wc == L'\\')
287226
  		{
287226
! 		  wc = *wpat++;
287226
! 		  if (*wpat == 0)
287226
! 		    break;
287226
  		}
287226
  	      else if (wc == L'[' && *wpat == L':')	/* character class */
287226
  		{
287226
  		  wpat++;
287226
  		  in_cclass = 1;
287226
  		}
287226
--- 125,148 ----
287226
  	      if (wc == 0)
287226
  		{
287226
! 		  wpat--;			/* back up to NUL */
287226
! 	          matlen += bracklen;
287226
! 	          goto bad_bracket;
287226
  	        }
287226
  	      else if (wc == L'\\')
287226
  		{
287226
! 		  /* *wpat == backslash-escaped character */
287226
! 		  bracklen++;
287226
! 		  /* If the backslash or backslash-escape ends the string,
287226
! 		     bail.  The ++wpat skips over the backslash escape */
287226
! 		  if (*wpat == 0 || *++wpat == 0)
287226
! 		    {
287226
! 		      matlen += bracklen;
287226
! 		      goto bad_bracket;
287226
! 		    }
287226
  		}
287226
  	      else if (wc == L'[' && *wpat == L':')	/* character class */
287226
  		{
287226
  		  wpat++;
287226
+ 		  bracklen++;
287226
  		  in_cclass = 1;
287226
  		}
287226
***************
287226
*** 142,145 ****
287226
--- 150,154 ----
287226
  		{
287226
  		  wpat++;
287226
+ 		  bracklen++;
287226
  		  in_cclass = 0;
287226
  		}
287226
***************
287226
*** 147,152 ****
287226
  		{
287226
  		  wpat++;
287226
  		  if (*wpat == L']')	/* right bracket can appear as collating symbol */
287226
! 		    wpat++;
287226
  		  in_collsym = 1;
287226
  		}
287226
--- 156,165 ----
287226
  		{
287226
  		  wpat++;
287226
+ 		  bracklen++;
287226
  		  if (*wpat == L']')	/* right bracket can appear as collating symbol */
287226
! 		    {
287226
! 		      wpat++;
287226
! 		      bracklen++;
287226
! 		    }
287226
  		  in_collsym = 1;
287226
  		}
287226
***************
287226
*** 154,157 ****
287226
--- 167,171 ----
287226
  		{
287226
  		  wpat++;
287226
+ 		  bracklen++;
287226
  		  in_collsym = 0;
287226
  		}
287226
***************
287226
*** 159,164 ****
287226
  		{
287226
  		  wpat++;
287226
  		  if (*wpat == L']')	/* right bracket can appear as equivalence class */
287226
! 		    wpat++;
287226
  		  in_equiv = 1;
287226
  		}
287226
--- 173,182 ----
287226
  		{
287226
  		  wpat++;
287226
+ 		  bracklen++;
287226
  		  if (*wpat == L']')	/* right bracket can appear as equivalence class */
287226
! 		    {
287226
! 		      wpat++;
287226
! 		      bracklen++;
287226
! 		    }
287226
  		  in_equiv = 1;
287226
  		}
287226
***************
287226
*** 166,174 ****
287226
--- 184,196 ----
287226
  		{
287226
  		  wpat++;
287226
+ 		  bracklen++;
287226
  		  in_equiv = 0;
287226
  		}
287226
+ 	      else
287226
+ 		bracklen++;
287226
  	    }
287226
  	  while ((wc = *wpat++) != L']');
287226
  	  matlen++;		/* bracket expression can only match one char */
287226
+ bad_bracket:
287226
  	  break;
287226
  	}
287226
***************
287226
*** 214,219 ****
287226
       size_t max;
287226
  {
287226
!   char c, *brack;
287226
!   int matlen, t, in_cclass, in_collsym, in_equiv;
287226
  
287226
    if (*pat == 0)
287226
--- 236,241 ----
287226
       size_t max;
287226
  {
287226
!   char c;
287226
!   int matlen, bracklen, t, in_cclass, in_collsym, in_equiv;
287226
  
287226
    if (*pat == 0)
287226
***************
287226
*** 255,259 ****
287226
  	case '[':
287226
  	  /* scan for ending `]', skipping over embedded [:...:] */
287226
! 	  brack = pat;
287226
  	  c = *pat++;
287226
  	  do
287226
--- 277,281 ----
287226
  	case '[':
287226
  	  /* scan for ending `]', skipping over embedded [:...:] */
287226
! 	  bracklen = 1;
287226
  	  c = *pat++;
287226
  	  do
287226
***************
287226
*** 261,276 ****
287226
  	      if (c == 0)
287226
  		{
287226
! 	          matlen += pat - brack - 1;	/* incremented below */
287226
! 	          break;
287226
  	        }
287226
  	      else if (c == '\\')
287226
  		{
287226
! 		  c = *pat++;
287226
! 		  if (*pat == 0)
287226
! 		    break;
287226
  		}
287226
  	      else if (c == '[' && *pat == ':')	/* character class */
287226
  		{
287226
  		  pat++;
287226
  		  in_cclass = 1;
287226
  		}
287226
--- 283,306 ----
287226
  	      if (c == 0)
287226
  		{
287226
! 		  pat--;			/* back up to NUL */
287226
! 		  matlen += bracklen;
287226
! 		  goto bad_bracket;
287226
  	        }
287226
  	      else if (c == '\\')
287226
  		{
287226
! 		  /* *pat == backslash-escaped character */
287226
! 		  bracklen++;
287226
! 		  /* If the backslash or backslash-escape ends the string,
287226
! 		     bail.  The ++pat skips over the backslash escape */
287226
! 		  if (*pat == 0 || *++pat == 0)
287226
! 		    {
287226
! 		      matlen += bracklen;
287226
! 		      goto bad_bracket;
287226
! 		    }
287226
  		}
287226
  	      else if (c == '[' && *pat == ':')	/* character class */
287226
  		{
287226
  		  pat++;
287226
+ 		  bracklen++;
287226
  		  in_cclass = 1;
287226
  		}
287226
***************
287226
*** 278,281 ****
287226
--- 308,312 ----
287226
  		{
287226
  		  pat++;
287226
+ 		  bracklen++;
287226
  		  in_cclass = 0;
287226
  		}
287226
***************
287226
*** 283,288 ****
287226
  		{
287226
  		  pat++;
287226
  		  if (*pat == ']')	/* right bracket can appear as collating symbol */
287226
! 		    pat++;
287226
  		  in_collsym = 1;
287226
  		}
287226
--- 314,323 ----
287226
  		{
287226
  		  pat++;
287226
+ 		  bracklen++;
287226
  		  if (*pat == ']')	/* right bracket can appear as collating symbol */
287226
! 		    {
287226
! 		      pat++;
287226
! 		      bracklen++;
287226
! 		    }
287226
  		  in_collsym = 1;
287226
  		}
287226
***************
287226
*** 290,293 ****
287226
--- 325,329 ----
287226
  		{
287226
  		  pat++;
287226
+ 		  bracklen++;
287226
  		  in_collsym = 0;
287226
  		}
287226
***************
287226
*** 295,300 ****
287226
  		{
287226
  		  pat++;
287226
  		  if (*pat == ']')	/* right bracket can appear as equivalence class */
287226
! 		    pat++;
287226
  		  in_equiv = 1;
287226
  		}
287226
--- 331,340 ----
287226
  		{
287226
  		  pat++;
287226
+ 		  bracklen++;
287226
  		  if (*pat == ']')	/* right bracket can appear as equivalence class */
287226
! 		    {
287226
! 		      pat++;
287226
! 		      bracklen++;
287226
! 		    }
287226
  		  in_equiv = 1;
287226
  		}
287226
***************
287226
*** 302,310 ****
287226
--- 342,354 ----
287226
  		{
287226
  		  pat++;
287226
+ 		  bracklen++;
287226
  		  in_equiv = 0;
287226
  		}
287226
+ 	      else
287226
+ 		bracklen++;
287226
  	    }
287226
  	  while ((c = *pat++) != ']');
287226
  	  matlen++;		/* bracket expression can only match one char */
287226
+ bad_bracket:
287226
  	  break;
287226
  	}
287226
*** ../bash-4.2-patched/patchlevel.h	Sat Jun 12 20:14:48 2010
287226
--- patchlevel.h	Thu Feb 24 21:41:34 2011
287226
***************
287226
*** 26,30 ****
287226
     looks for to find the patch level (for the sccs version string). */
287226
  
287226
! #define PATCHLEVEL 2
287226
  
287226
  #endif /* _PATCHLEVEL_H_ */
287226
--- 26,30 ----
287226
     looks for to find the patch level (for the sccs version string). */
287226
  
287226
! #define PATCHLEVEL 3
287226
  
287226
  #endif /* _PATCHLEVEL_H_ */