Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1622)

Unified Diff: scripts/image_signing/ensure_secure_kernelparams.sh

Issue 6538034: Fix issue where params which are sub-strings of other params caused problems e.g. ro and cros_secure (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git@master
Patch Set: Fixes for nits Created 9 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: scripts/image_signing/ensure_secure_kernelparams.sh
diff --git a/scripts/image_signing/ensure_secure_kernelparams.sh b/scripts/image_signing/ensure_secure_kernelparams.sh
index 1d159d4c6c1d42ce85ebc7f01647e42a28155620..29fab35e343f5bed30a8dd777145b16d7256fc88 100755
--- a/scripts/image_signing/ensure_secure_kernelparams.sh
+++ b/scripts/image_signing/ensure_secure_kernelparams.sh
@@ -32,6 +32,12 @@ dmparams_mangle_sha1() {
echo "$1" | sed 's/sha1 [0-9a-fA-F]*/sha1 MAGIC_HASH/'
}
+# This escapes any non-alphanum character, since many such characters
+# are regex metacharacters.
+escape_regexmetas() {
+ echo "$1" | sed 's/\([^a-zA-Z0-9]\)/\\\1/g'
+}
+
usage() {
echo "Usage $PROG image [config]"
}
@@ -86,20 +92,22 @@ main() {
fi
# Ensure all other required params are present.
- for param in ${required_kparams[@]}; do :
+ for param in ${required_kparams[@]}; do
if [[ "$kparams_nodm" != *$param* ]]; then
echo "Kernel parameters missing required value: $param"
testfail=1
else
# Remove matched params as we go. If all goes well, kparams_nodm
# will be nothing left but whitespace by the end.
- kparams_nodm=${kparams_nodm/$param/}
+ param=$(escape_regexmetas "$param")
+ kparams_nodm=$(echo "$kparams_nodm" | sed "s/\b$param\b//")
fi
done
# Check-off each of the allowed-but-optional params that were present.
- for param in ${optional_kparams[@]}; do :
- kparams_nodm=${kparams_nodm/$param/}
+ for param in ${optional_kparams[@]}; do
+ param=$(escape_regexmetas "$param")
+ kparams_nodm=$(echo "$kparams_nodm" | sed "s/\b$param\b//")
done
# This section enforces the default-deny for any unexpected params
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698