mirror of
https://github.com/flatcar/scripts.git
synced 2025-09-23 06:31:18 +02:00
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 <jglasgow@chromium.org> Reviewed-by: David James <davidjames@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
b623f321b9
commit
bc36d041f0
@ -263,6 +263,11 @@ function get_default_board {
|
|||||||
|
|
||||||
if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then
|
if [ -f "$GCLIENT_ROOT/src/scripts/.default_board" ] ; then
|
||||||
DEFAULT_BOARD=$(cat "$GCLIENT_ROOT/src/scripts/.default_board")
|
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
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user