mirror of
https://github.com/flatcar/scripts.git
synced 2025-11-24 03:51:33 +01:00
Escape open bracket when parsing config file.
Section header like [x86-zgb] would match any single-character
file/directory name within 6-z. Escape open brackets to prevent
config section headers from being evaluated to match local files.
BUG=chromium-os:21518
TEST=1. Create a single-character file 'u', under the same
directory where you'll run make_factory_package.
2. Create a test.conf with section header "x86-zgb".
3. ./make_factory_package.sh --config test.conf
4. Verify u is not part of the executed command.
Change-Id: Ia6178b7fc2f8d707830ee7fed54f9e5ab60d6836
Reviewed-on: http://gerrit.chromium.org/gerrit/10012
Tested-by: Chinyue Chen <chinyue@chromium.org>
Reviewed-by: Hung-Te Lin <hungte@chromium.org>
Commit-Ready: Chinyue Chen <chinyue@chromium.org>
This commit is contained in:
parent
eeaf674db4
commit
342dbdaf10
@ -650,12 +650,10 @@ parse_and_run_config() {
|
|||||||
local config_file="$1"
|
local config_file="$1"
|
||||||
local -a cmds
|
local -a cmds
|
||||||
local cmd=""
|
local cmd=""
|
||||||
|
local line
|
||||||
|
|
||||||
echo "Read parameters from: $config_file"
|
echo "Read parameters from: $config_file"
|
||||||
local config="$(<$config_file)"
|
while read line; do
|
||||||
local IFS=$'\n'
|
|
||||||
for line in $config
|
|
||||||
do
|
|
||||||
if [[ "$line" =~ ^\[.*] ]]; then
|
if [[ "$line" =~ ^\[.*] ]]; then
|
||||||
if [ -n "$cmd" ]; then
|
if [ -n "$cmd" ]; then
|
||||||
cmds+=("$cmd")
|
cmds+=("$cmd")
|
||||||
@ -665,7 +663,7 @@ parse_and_run_config() {
|
|||||||
fi
|
fi
|
||||||
line="${line%%#*}"
|
line="${line%%#*}"
|
||||||
cmd="$cmd $line"
|
cmd="$cmd $line"
|
||||||
done
|
done < "$config_file"
|
||||||
if [ -n "$cmd" ]; then
|
if [ -n "$cmd" ]; then
|
||||||
cmds+=("$cmd")
|
cmds+=("$cmd")
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user