summaryrefslogtreecommitdiff
path: root/cmd
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2020-05-31 22:46:09 +0200
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2020-06-03 17:19:17 +0200
commit0e69bcfb27644f9e7c575aa3565bcff922c7dec2 (patch)
tree1560106fb519adf2d1ac3f6214cc4383df2b0b49 /cmd
parentecd4d99f654f3f7bfb96001891d69c3125e70b69 (diff)
downloadu-boot-0e69bcfb27644f9e7c575aa3565bcff922c7dec2.tar.gz
u-boot-0e69bcfb27644f9e7c575aa3565bcff922c7dec2.tar.bz2
u-boot-0e69bcfb27644f9e7c575aa3565bcff922c7dec2.zip
efi_loader: validate load option
For passing the optional data of the load option to the loaded imaged protocol we need its size. efi_deserialize_load_option() is changed to return the size of the optional data. As a by-product we get a partial validation of the load option. Checking the length of the device path remains to be implemented. Some Coverity defects identified the load options as user input because get_unaligned_le32() and get_unaligned_le16() is called. But non of these Coverity defects can be resolved without marking functions with Coverity specific tags. Reported-by: Coverity (CID 303760) Reported-by: Coverity (CID 303768) Reported-by: Coverity (CID 303776) Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'cmd')
-rw-r--r--cmd/efidebug.c21
1 files changed, 15 insertions, 6 deletions
diff --git a/cmd/efidebug.c b/cmd/efidebug.c
index 32430e62f0..58018f700c 100644
--- a/cmd/efidebug.c
+++ b/cmd/efidebug.c
@@ -694,14 +694,19 @@ static int do_efi_boot_rm(struct cmd_tbl *cmdtp, int flag,
*
* Decode the value of UEFI load option variable and print information.
*/
-static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t size)
+static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t *size)
{
struct efi_load_option lo;
char *label, *p;
size_t label_len16, label_len;
u16 *dp_str;
+ efi_status_t ret;
- efi_deserialize_load_option(&lo, data);
+ ret = efi_deserialize_load_option(&lo, data, size);
+ if (ret != EFI_SUCCESS) {
+ printf("%ls: invalid load option\n", varname16);
+ return;
+ }
label_len16 = u16_strlen(lo.label);
label_len = utf16_utf8_strnlen(lo.label, label_len16);
@@ -728,8 +733,7 @@ static void show_efi_boot_opt_data(u16 *varname16, void *data, size_t size)
printf(" data:\n");
print_hex_dump(" ", DUMP_PREFIX_OFFSET, 16, 1,
- lo.optional_data, size + (u8 *)data -
- (u8 *)lo.optional_data, true);
+ lo.optional_data, *size, true);
free(label);
}
@@ -759,7 +763,7 @@ static void show_efi_boot_opt(u16 *varname16)
&efi_global_variable_guid,
NULL, &size, data));
if (ret == EFI_SUCCESS)
- show_efi_boot_opt_data(varname16, data, size);
+ show_efi_boot_opt_data(varname16, data, &size);
free(data);
}
}
@@ -920,7 +924,12 @@ static int show_efi_boot_order(void)
goto out;
}
- efi_deserialize_load_option(&lo, data);
+ ret = efi_deserialize_load_option(&lo, data, &size);
+ if (ret != EFI_SUCCESS) {
+ printf("%ls: invalid load option\n", var_name16);
+ ret = CMD_RET_FAILURE;
+ goto out;
+ }
label_len16 = u16_strlen(lo.label);
label_len = utf16_utf8_strnlen(lo.label, label_len16);