[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: (( arr[${var@Q}] )) makes the shell crash in bash-5.2
From: |
Koichi Murase |
Subject: |
Re: (( arr[${var@Q}] )) makes the shell crash in bash-5.2 |
Date: |
Fri, 30 Sep 2022 20:15:32 +0900 |
2022年9月30日(金) 19:50 Koichi Murase <myoga.murase@gmail.com>:
> 2022年9月30日(金) 19:37 Emanuele Torre <torreemanuele6@gmail.com>:
> > In bash-5.2, using the ${parameter@Q} parameter expansion with an unset
> > parameter, in an array subscript, in an arithmetic context, causes a
> > segmentation fault.
>
> It seems even ((y[$a])) in arithmetic contexts causes a segfault:
I attach a patch [0001-subst-handle-null-substring.patch]. This is
caused in the following way: In `expand_array_subscript' (subst.c),
NULL is returned by `expand_subscript_string' and is passed to
`sh_backslash_quote', but `sh_backslash_quote' assumes a non-NULL
pointer to a string as the first argument. FYI, this is the backtrace
in my system:
(gdb) bt
#0 0x00007ffff7d5b7fd in __strlen_avx2 () from /lib64/libc.so.6
#1 0x00000000004cff6e in sh_backslash_quote ()
#2 0x000000000047837c in expand_word_internal ()
#3 0x000000000047ddba in expand_arith_string ()
#4 0x000000000043fd06 in execute_command_internal ()
#5 0x00000000004ae8c1 in parse_and_execute ()
#6 0x000000000042417a in run_one_command.isra ()
#7 0x0000000000422bda in main ()
--
Koichi
0001-subst-handle-null-substring.patch.txt
Description: Text document