On 2/1/12 8:01 PM, Jim Avera wrote:
> Configuration Information [Automatically generated, do not change]:
> Machine: x86_64
> OS: linux-gnu
> Compiler: gcc
> Compilation CFLAGS:  -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64'
> -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu'
> -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE='bash' -DSHELL
> -DHAVE_CONFIG_H   -I.  -I../bash -I../bash/include -I../bash/lib   -g -O2
> -Wall
> uname output: Linux lxjima 3.0.0-15-generic #26-Ubuntu SMP Fri Jan 20
> 17:23:00 UTC 2012 x86_64 x86_64 x86_64 GNU/Linux
> Machine Type: x86_64-pc-linux-gnu
> 
> Bash Version: 4.2
> Patch Level: 10
> Release Status: release
> 
> Description:
> 
> If printf is used to set an array element, and the format
> contains %b and the corresponding arg is empty, then the
> array is somehow poisoned such that later use of array[*] or [@]
> causes a segfault.
> 
> No segfault occurs if the string interpolated by %b is not empty,
> or if %s is used instead of %b (in those cases, setting an array
> element with printf seems to work fine).

Thanks for the report.  It's a combination, as you surmised, of %b
and -v.  Here's a patch that should fix it.

Chet
-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    c...@case.edu    http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.2-patched/builtins/printf.def	2011-02-25 12:07:41.000000000 -0500
--- builtins/printf.def	2012-02-02 08:37:12.000000000 -0500
***************
*** 256,259 ****
--- 257,262 ----
  	    {
  	      vflag = 1;
+ 	      if (vbsize == 0)
+ 		vbuf = xmalloc (vbsize = 16);
  	      vblen = 0;
  	      if (vbuf)

Reply via email to