From 342dbdaf104b2fc18075bd9f18f93491cc103529 Mon Sep 17 00:00:00 2001 From: Chinyue Chen Date: Thu, 13 Oct 2011 14:50:33 +0800 Subject: [PATCH] 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 Reviewed-by: Hung-Te Lin Commit-Ready: Chinyue Chen --- make_factory_package.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/make_factory_package.sh b/make_factory_package.sh index 1fc35b6dfb..0fbfa03da6 100755 --- a/make_factory_package.sh +++ b/make_factory_package.sh @@ -650,12 +650,10 @@ parse_and_run_config() { local config_file="$1" local -a cmds local cmd="" + local line echo "Read parameters from: $config_file" - local config="$(<$config_file)" - local IFS=$'\n' - for line in $config - do + while read line; do if [[ "$line" =~ ^\[.*] ]]; then if [ -n "$cmd" ]; then cmds+=("$cmd") @@ -665,7 +663,7 @@ parse_and_run_config() { fi line="${line%%#*}" cmd="$cmd $line" - done + done < "$config_file" if [ -n "$cmd" ]; then cmds+=("$cmd") fi