From b40ea5be1811e801a36ac9241df876f0ca723fa7 Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Mon, 15 Oct 2018 15:25:43 +0200 Subject: [PATCH] grubby-bls: check if entry exists before attempting to print its info The grubby --info option didn't check if an entry existed for a kernel and printed wrong information about it. Fix this and also for --update-kernel and --set-default options that have the same issue. Resolves: rhbz#1634712 Signed-off-by: Javier Martinez Canillas --- grubby-bls | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/grubby-bls b/grubby-bls index 99a57bd..c9c608b 100755 --- a/grubby-bls +++ b/grubby-bls @@ -188,6 +188,10 @@ param_to_indexes() { display_info_values() { local indexes=($(param_to_indexes "$1")) + if [[ $indexes = "-1" ]]; then + print_error "The param $1 is incorrect" + fi + for i in ${indexes[*]}; do echo "index=$i" echo "kernel=${bls_linux[$i]}" @@ -358,6 +362,10 @@ update_bls_fragment() { local add_args=$1 && shift local initrd=$1 && shift + if [[ $indexes = "-1" ]]; then + print_error "The param $1 is incorrect" + fi + for i in ${indexes[*]}; do if [[ -n $remove_args || -n $add_args ]]; then local new_args="$(update_args "${bls_options[$i]}" "${remove_args}" "${add_args}")" @@ -375,6 +383,10 @@ update_bls_fragment() { set_default_bls() { local index=($(param_to_indexes "$1")) + if [[ $index = "-1" ]]; then + print_error "The param $1 is incorrect" + fi + if [[ $bootloader = grub2 ]]; then grub2-editenv "${env}" set saved_entry="${bls_id[$index]}" else