summaryrefslogtreecommitdiff
path: root/cmd/efidebug.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-04-29 20:21:39 +0200
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2020-04-30 10:25:07 +0200
commitdd9056c06a0557bc08ca986530024568e01ede6f (patch)
tree68ccc003f347fd6a2a00a001907e1cfe28e1c4db /cmd/efidebug.c
parentb5f4e9e384c36234a0e7f1c60957f369c4c05b5e (diff)
efi_loader: efidebug, avoid illegal memory access
For EFI_PERSISTENT_MEMORY_TYPE the 'efidebug memmap' command produces an illegal memory access. * Add the missing descriptive string for EFI_PERSISTENT_MEMORY_TYPE. * Replace the check for EFI_MAX_MEMORY_TYPE by the ARRAY_SIZE() macro. Reported-by: Coverity (CID 300336) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'cmd/efidebug.c')
-rw-r--r--cmd/efidebug.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 7ff2ce4ce1..53cb3cbfaf 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -395,6 +395,7 @@ static const char * const efi_mem_type_string[] = {
[EFI_MMAP_IO] = "IO",
[EFI_MMAP_IO_PORT] = "IO PORT",
[EFI_PAL_CODE] = "PAL",
+ [EFI_PERSISTENT_MEMORY_TYPE] = "PERSISTENT",
};
static const struct efi_mem_attrs {
@@ -482,7 +483,7 @@ static int do_efi_show_memmap(cmd_tbl_t *cmdtp, int flag,
printf("================ %.*s %.*s ==========\n",
EFI_PHYS_ADDR_WIDTH, sep, EFI_PHYS_ADDR_WIDTH, sep);
for (i = 0, map = memmap; i < map_size / sizeof(*map); map++, i++) {
- if (map->type < EFI_MAX_MEMORY_TYPE)
+ if (map->type < ARRAY_SIZE(efi_mem_type_string))
type = efi_mem_type_string[map->type];
else
type = "(unknown)";