From 1fd9fce46d11a9bbafa0aa75af9500eb76ffa4be Mon Sep 17 00:00:00 2001 From: Corey Hickey Date: Fri, 12 Jan 2018 11:01:18 -0800 Subject: [PATCH] exit on invalid varient If this happens, it's a bug in the script. None of the calling code checks for status 255, so don't let a scripting bug cause a false negative. --- spectre-meltdown-checker.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/spectre-meltdown-checker.sh b/spectre-meltdown-checker.sh index 69f2dd5..6409c47 100755 --- a/spectre-meltdown-checker.sh +++ b/spectre-meltdown-checker.sh @@ -151,7 +151,7 @@ _debug() is_cpu_vulnerable() { # param: 1, 2 or 3 (variant) - # returns 0 if vulnerable, 1 if not vulnerable, 255 on error + # returns 0 if vulnerable, 1 if not vulnerable # (note that in shell, a return of 0 is success) # by default, everything is vulnerable, we work in a "whitelist" logic here. # usage: is_cpu_vulnerable 2 && do something if vulnerable @@ -196,7 +196,8 @@ is_cpu_vulnerable() [ "$1" = 1 ] && return $variant1 [ "$1" = 2 ] && return $variant2 [ "$1" = 3 ] && return $variant3 - return 255 + echo "$0: error: invalid variant '$1' passed to is_cpu_vulnerable()" >&2 + exit 1 } show_header()