summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoel Kitching <kitching@google.com>2019-08-01 12:45:47 +0800
committerCommit Bot <commit-bot@chromium.org>2019-08-13 13:03:55 +0000
commit7ceb2ae796e6cd2b38a3344cffc8aa93032345ec (patch)
treeca660310a09ce55b8009366940708277ae9f3c37
parent7ad9f51996d9d950dfbf6c11c82144f7026a68aa (diff)
downloadvboot-7ceb2ae796e6cd2b38a3344cffc8aa93032345ec.tar.gz
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 <kitching@google.com> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/vboot_reference/+/1729773 Commit-Queue: Joel Kitching <kitching@chromium.org> Tested-by: Joel Kitching <kitching@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--firmware/lib/vboot_ui_menu.c5
-rw-r--r--tests/vboot_detach_menu_tests.c5
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++;