Roman Rakus 928cba
			     BASH PATCH REPORT
Roman Rakus 928cba
			     =================
Roman Rakus 928cba
Roman Rakus 928cba
Bash-Release: 4.0
Roman Rakus 928cba
Patch-ID: bash40-024
Roman Rakus 928cba
Roman Rakus 928cba
Bug-Reported-by:  Matt Zyzik <matt.zyzik@nyu.edu>
Roman Rakus 928cba
Bug-Reference-ID:  <20090405205428.4FDEA1C7175@ice.filescope.com>
Roman Rakus 928cba
Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2009-04/msg00021.html
Roman Rakus 928cba
Roman Rakus 928cba
Bug-Description:
Roman Rakus 928cba
Roman Rakus 928cba
When using the ** globbing operator, bash will incorrectly add an extra
Roman Rakus 928cba
directory name when the preceding directory name ends with `*' or an empty
Roman Rakus 928cba
string when there is no preceding directory name.
Roman Rakus 928cba
Roman Rakus 928cba
Patch:
Roman Rakus 928cba
Roman Rakus 928cba
*** ../bash-4.0-patched/lib/glob/glob.c	2009-01-04 14:32:30.000000000 -0500
Roman Rakus 928cba
--- lib/glob/glob.c	2009-04-28 10:22:29.000000000 -0400
Roman Rakus 928cba
***************
Roman Rakus 928cba
*** 357,361 ****
Roman Rakus 928cba
        if (ep)
Roman Rakus 928cba
          *ep = 0;
Roman Rakus 928cba
!       if (r)
Roman Rakus 928cba
  	free (r);
Roman Rakus 928cba
        return (struct globval *)0;
Roman Rakus 928cba
--- 357,361 ----
Roman Rakus 928cba
        if (ep)
Roman Rakus 928cba
          *ep = 0;
Roman Rakus 928cba
!       if (r && r != &glob_error_return)
Roman Rakus 928cba
  	free (r);
Roman Rakus 928cba
        return (struct globval *)0;
Roman Rakus 928cba
***************
Roman Rakus 928cba
*** 666,671 ****
Roman Rakus 928cba
      }
Roman Rakus 928cba
  
Roman Rakus 928cba
!   /* compat: if GX_ALLDIRS, add the passed directory also */
Roman Rakus 928cba
!   if (add_current)
Roman Rakus 928cba
      {
Roman Rakus 928cba
        sdlen = strlen (dir);
Roman Rakus 928cba
--- 666,672 ----
Roman Rakus 928cba
      }
Roman Rakus 928cba
  
Roman Rakus 928cba
!   /* compat: if GX_ALLDIRS, add the passed directory also, but don't add an
Roman Rakus 928cba
!      empty directory name. */
Roman Rakus 928cba
!   if (add_current && (flags & GX_NULLDIR) == 0)
Roman Rakus 928cba
      {
Roman Rakus 928cba
        sdlen = strlen (dir);
Roman Rakus 928cba
***************
Roman Rakus 928cba
*** 679,686 ****
Roman Rakus 928cba
  	  nextlink->next = lastlink;
Roman Rakus 928cba
  	  lastlink = nextlink;
Roman Rakus 928cba
! 	  if (flags & GX_NULLDIR)
Roman Rakus 928cba
! 	    nextname[0] = '\0';
Roman Rakus 928cba
! 	  else
Roman Rakus 928cba
! 	    bcopy (dir, nextname, sdlen + 1);
Roman Rakus 928cba
  	  ++count;
Roman Rakus 928cba
  	}
Roman Rakus 928cba
--- 680,684 ----
Roman Rakus 928cba
  	  nextlink->next = lastlink;
Roman Rakus 928cba
  	  lastlink = nextlink;
Roman Rakus 928cba
! 	  bcopy (dir, nextname, sdlen + 1);
Roman Rakus 928cba
  	  ++count;
Roman Rakus 928cba
  	}
Roman Rakus 928cba
***************
Roman Rakus 928cba
*** 943,947 ****
Roman Rakus 928cba
  	      register unsigned int l;
Roman Rakus 928cba
  
Roman Rakus 928cba
! 	      array = glob_dir_to_array (directories[i], temp_results, flags);
Roman Rakus 928cba
  	      l = 0;
Roman Rakus 928cba
  	      while (array[l] != NULL)
Roman Rakus 928cba
--- 941,950 ----
Roman Rakus 928cba
  	      register unsigned int l;
Roman Rakus 928cba
  
Roman Rakus 928cba
! 	      /* If we're expanding **, we don't need to glue the directory
Roman Rakus 928cba
! 		 name to the results; we've already done it in glob_vector */
Roman Rakus 928cba
! 	      if ((dflags & GX_ALLDIRS) && filename[0] == '*' && filename[1] == '*' && filename[2] == '\0')
Roman Rakus 928cba
! 		array = temp_results;
Roman Rakus 928cba
! 	      else
Roman Rakus 928cba
! 		array = glob_dir_to_array (directories[i], temp_results, flags);
Roman Rakus 928cba
  	      l = 0;
Roman Rakus 928cba
  	      while (array[l] != NULL)
Roman Rakus 928cba
***************
Roman Rakus 928cba
*** 960,964 ****
Roman Rakus 928cba
  
Roman Rakus 928cba
  	      /* Note that the elements of ARRAY are not freed.  */
Roman Rakus 928cba
! 	      free ((char *) array);
Roman Rakus 928cba
  	    }
Roman Rakus 928cba
  	}
Roman Rakus 928cba
--- 963,968 ----
Roman Rakus 928cba
  
Roman Rakus 928cba
  	      /* Note that the elements of ARRAY are not freed.  */
Roman Rakus 928cba
! 	      if (array != temp_results)
Roman Rakus 928cba
! 		free ((char *) array);
Roman Rakus 928cba
  	    }
Roman Rakus 928cba
  	}
Roman Rakus 928cba
*** ../bash-4.0/patchlevel.h	2009-01-04 14:32:40.000000000 -0500
Roman Rakus 928cba
--- patchlevel.h	2009-02-22 16:11:31.000000000 -0500
Roman Rakus 928cba
***************
Roman Rakus 928cba
*** 26,30 ****
Roman Rakus 928cba
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 928cba
  
Roman Rakus 928cba
! #define PATCHLEVEL 23
Roman Rakus 928cba
  
Roman Rakus 928cba
  #endif /* _PATCHLEVEL_H_ */
Roman Rakus 928cba
--- 26,30 ----
Roman Rakus 928cba
     looks for to find the patch level (for the sccs version string). */
Roman Rakus 928cba
  
Roman Rakus 928cba
! #define PATCHLEVEL 24
Roman Rakus 928cba
  
Roman Rakus 928cba
  #endif /* _PATCHLEVEL_H_ */