From ecc6f6bea6a29e43f4c559aeb642e0597cf702b2 Mon Sep 17 00:00:00 2001 From: Ievgen Maliarenko Date: Tue, 14 Aug 2018 02:43:03 +0200 Subject: [PATCH] libavb: Handle wrong hashtree_error_mode in avb_append_options() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Exit with AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT when hashtree_error_mode value passed to avb_append_options() is unknown (not from AvbHashtreeErrorMode enum). Otherwise, default value is not handled in the switch(hashtree_error_mode), which causes below compile warning: lib/libavb/avb_cmdline.c: In function ‘avb_append_options’: lib/libavb/avb_cmdline.c:354:13: warning: ‘dm_verity_mode’ may be used uninitialized in this function [-Wmaybe-uninitialized] new_ret = avb_replace( ~~~~~~~~^~~~~~~~~~~~~~ slot_data->cmdline, "$(ANDROID_VERITY_MODE)", dm_verity_mode); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ lib/libavb/avb_cmdline.c:363:8: warning: ‘verity_mode’ may be used uninitialized in this function [-Wmaybe-uninitialized] if (!cmdline_append_option( ^~~~~~~~~~~~~~~~~~~~~~ slot_data, "androidboot.veritymode", verity_mode)) { Signed-off-by: Ievgen Maliarenko Signed-off-by: Eugeniu Rosca Reviewed-by: Igor Opaniuk --- lib/libavb/avb_cmdline.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/libavb/avb_cmdline.c b/lib/libavb/avb_cmdline.c index 91a6615c74..d246699272 100644 --- a/lib/libavb/avb_cmdline.c +++ b/lib/libavb/avb_cmdline.c @@ -331,6 +331,9 @@ AvbSlotVerifyResult avb_append_options( verity_mode = "logging"; dm_verity_mode = "ignore_corruption"; break; + default: + ret = AVB_SLOT_VERIFY_RESULT_ERROR_INVALID_ARGUMENT; + goto out; } new_ret = avb_replace( slot_data->cmdline, "$(ANDROID_VERITY_MODE)", dm_verity_mode); -- 2.25.1