bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

printf -v array[$i] "%b" "" poisons array causing segfault later


From: Jim Avera
Subject: printf -v array[$i] "%b" "" poisons array causing segfault later
Date: Wed, 01 Feb 2012 17:01:46 -0800
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:9.0) Gecko/20111229 Thunderbird/9.0

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).

Repeat-By:
   bash -c 'declare -a ary; printf -v ary[0] "%b" ""; x="${ary[*]}"'

#!/bin/bash
declare -a ary
printf -v ary[0] "%b" ""
echo "after printf"
x="${ary[*]}"  # segfaults here
echo "after use"



reply via email to

[Prev in Thread] Current Thread [Next in Thread]