[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: printf -v array[$i] "%b" "" poisons array causing segfault later
From: |
Chet Ramey |
Subject: |
Re: printf -v array[$i] "%b" "" poisons array causing segfault later |
Date: |
Thu, 02 Feb 2012 09:01:30 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
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 chet@case.edu http://cnswww.cns.cwru.edu/~chet/
printf-nullstr.patch
Description: Source code patch