[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Improper array name validation for the 'mapfile' builtin
From: |
Eduardo A . Bustamante López |
Subject: |
Improper array name validation for the 'mapfile' builtin |
Date: |
Mon, 17 Nov 2014 23:50:48 -0600 |
User-agent: |
Mutt/1.5.23 (2014-03-12) |
Hi Chet,
It seems like the variable name validation for the mapfile builtin is a bit
wrong. I hope the patch below fixes it.
Demonstration:
| dualbus@hp ...local/src/bash % : before patch
| dualbus@hp ...local/src/bash % /bin/bash -c 'mapfile -t "a[\$(ls)]" <<< "";
declare -p'|grep -F '[$('
| declare -a a[$(ls)]='([0]="")'
|
| dualbus@hp ...local/src/bash % : after patch
| dualbus@hp ...local/src/bash % ./bash -c 'mapfile -t "a[\$(ls)]" <<< "";
declare -p'|grep -F '[$('
| ./bash: line 0: mapfile: `a[$(ls)]': not a valid identifier
Patch:
diff --git a/builtins/mapfile.def b/builtins/mapfile.def
index 5e258bb..51e37c6 100644
--- a/builtins/mapfile.def
+++ b/builtins/mapfile.def
@@ -349,7 +349,7 @@ mapfile_builtin (list)
else
array_name = list->word->word;
- if (legal_identifier (array_name) == 0 && valid_array_reference (array_name)
== 0)
+ if (legal_identifier (array_name) == 0)
{
sh_invalidid (array_name);
return (EXECUTION_FAILURE);
- Improper array name validation for the 'mapfile' builtin,
Eduardo A . Bustamante López <=