From 7ceb2ae796e6cd2b38a3344cffc8aa93032345ec Mon Sep 17 00:00:00 2001 From: Joel Kitching Date: Thu, 1 Aug 2019 12:45:47 +0800 Subject: vboot: properly check failure from VbExGetLocalizationCount Check the return value and result of calling VbExGetLocalizationCount. If something is awry, fall back to using one language entry. BUG=b:124141368 TEST=make clean && make runtests BRANCH=none Change-Id: Ieeea54bfed303a98d16f15aceab47f1ffdd10d6d Signed-off-by: Joel Kitching Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1729773 Commit-Queue: Joel Kitching Tested-by: Joel Kitching Reviewed-by: Julius Werner --- firmware/lib/vboot_ui_menu.c | 5 ++--- tests/vboot_detach_menu_tests.c | 5 +++++ 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/firmware/lib/vboot_ui_menu.c b/firmware/lib/vboot_ui_menu.c index 628b6b89..3c202c28 100644 --- a/firmware/lib/vboot_ui_menu.c +++ b/firmware/lib/vboot_ui_menu.c @@ -713,9 +713,8 @@ static vb2_error_t vb2_init_menus(struct vb2_context *ctx) int i; /* Initialize language menu with the correct amount of entries. */ - VbExGetLocalizationCount(&count); - if (!count) - count = 1; /* Always need at least one language entry. */ + if (VB2_SUCCESS != VbExGetLocalizationCount(&count) || count == 0) + count = 1; /* Fall back to 1 language entry on failure */ items = malloc(count * sizeof(struct vb2_menu_item)); if (!items) diff --git a/tests/vboot_detach_menu_tests.c b/tests/vboot_detach_menu_tests.c index 613c8ef5..1a0c6175 100644 --- a/tests/vboot_detach_menu_tests.c +++ b/tests/vboot_detach_menu_tests.c @@ -134,6 +134,11 @@ struct vb2_gbb_header *vb2_get_gbb(struct vb2_context *c) return &gbb; } +vb2_error_t VbExGetLocalizationCount(uint32_t *count) { + *count = 1; + return VB2_SUCCESS; +} + uint32_t VbExGetAltFwIdxMask() { vbexaltfwmask_called++; -- cgit v1.2.1