[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Associative array keys are not reusable in (( command
From: |
Chet Ramey |
Subject: |
Re: Associative array keys are not reusable in (( command |
Date: |
Fri, 8 Jan 2021 10:41:18 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.6.0 |
On 1/8/21 10:24 AM, Oğuz wrote:
8 Ocak 2021 Cuma tarihinde Chet Ramey <chet.ramey@case.edu
<mailto:chet.ramey@case.edu>> yazdı:
On 1/8/21 5:20 AM, Oğuz wrote:
See:
$ declare -A assoc=($'\n\'' 42)
$ for key in "${!assoc[@]}"; do (( assoc[$key]++ )); done
bash: ((: assoc[
']++ : bad array subscript (error token is "assoc[
']++ ")
$
$ (( assoc[${key@Q}]++ ))
bash: ((: assoc[$'\n\'']++ : bad array subscript (error token is
"assoc[$'\n\'']++ ")
This situation is why bash-5.0 introduced the `assoc_expand_once' option.
But it allows arbitrary command injection.
If you want to run array keys through word expansions, this is one
potential result. Command substitution is "arbitrary command injection."
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
- Associative array keys are not reusable in (( command, Oğuz, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Koichi Murase, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Oğuz, 2021/01/08
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/10
- Re: Associative array keys are not reusable in (( command, Oğuz, 2021/01/10
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Greg Wooledge, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Oğuz, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Chet Ramey, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Greg Wooledge, 2021/01/11
- Re: Associative array keys are not reusable in (( command, Oğuz, 2021/01/11