From bc36d041f0d9c6270d898f8cd66fb66ef1938f67 Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 19 Dec 2011 16:01:09 -0500 Subject: [PATCH] get_default_board: detect invalid user settings If people have whitespace in their .default_board setting, then the cros utils will act weirdly. Some work the same as if there was no whitespace (probably because the variable is used unquoted) while others error out with weird messages (because the variable is used quoted). Update the helper function to only allow certain characters in the name. BUG=None TEST=`printf 'x86-alex\n' > .default_board; cros_workon list --all` works TEST=`printf 'x86-alex\t\n' > .default_board; cros_workon list --all` errors out Change-Id: Id83794c13bfddb7fb56b7f8ed8a375eefe6096e0 Reviewed-on: https://gerrit.chromium.org/gerrit/13151 Reviewed-by: Jason Glasgow Reviewed-by: David James Commit-Ready: Mike Frysinger Tested-by: Mike Frysinger --- common.sh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/common.sh b/common.sh index 89cb389f2d..a4f1d9b292 100644 --- a/common.sh +++ b/common.sh @@ -263,6 +263,11 @@ function get_default_board { if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then DEFAULT_BOARD=$(cat "$GCLIENT_ROOT/src/scripts/.default_board") + # Check for user typos like whitespace. + if [[ -n ${DEFAULT_BOARD//[a-zA-Z0-9-_]} ]] ; then + die ".default_board: invalid name detected; please fix:" \ + "'${DEFAULT_BOARD}'" + fi fi }