summaryrefslogtreecommitdiff
path: root/lib/efi_loader/efi_device_path.c
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2019-10-18 16:37:03 -0400
committerTom Rini <trini@konsulko.com>2019-10-18 16:37:03 -0400
commit4b5c4dd93a829416d159619e4a58e97e9b215206 (patch)
tree667242755939a72efebd99e815e0944c33174e4b /lib/efi_loader/efi_device_path.c
parent3b985bdeabd1b05abf28fe7dc6530c203750f9fc (diff)
parent5cc349bb09eefaf43e250b2c7a8fc5a61c595715 (diff)
Merge tag 'efi-2020-01-rc1-2' of https://gitlab.denx.de/u-boot/custodians/u-boot-efi
Pull request for UEFI sub-system for efi-2020-01-rc1 (2) Install the simple file protocol only if there is a file system on the partition. Enable CONFIG_CMD_NVEDIT_EFI on QEMU.
Diffstat (limited to 'lib/efi_loader/efi_device_path.c')
-rw-r--r--lib/efi_loader/efi_device_path.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/efi_loader/efi_device_path.c b/lib/efi_loader/efi_device_path.c
index 897fc1b2e8..ac5e6f7e14 100644
--- a/lib/efi_loader/efi_device_path.c
+++ b/lib/efi_loader/efi_device_path.c
@@ -15,6 +15,7 @@
#include <part.h>
#include <sandboxblockdev.h>
#include <asm-generic/unaligned.h>
+#include <linux/compat.h> /* U16_MAX */
#ifdef CONFIG_SANDBOX
const efi_guid_t efi_guid_host_dev = U_BOOT_HOST_DEV_GUID;
@@ -888,13 +889,16 @@ struct efi_device_path *efi_dp_from_file(struct blk_desc *desc, int part,
{
struct efi_device_path_file_path *fp;
void *buf, *start;
- unsigned dpsize = 0, fpsize;
+ size_t dpsize = 0, fpsize;
if (desc)
dpsize = dp_part_size(desc, part);
fpsize = sizeof(struct efi_device_path) +
2 * (utf8_utf16_strlen(path) + 1);
+ if (fpsize > U16_MAX)
+ return NULL;
+
dpsize += fpsize;
start = buf = dp_alloc(dpsize + sizeof(END));
@@ -908,7 +912,7 @@ struct efi_device_path *efi_dp_from_file(struct blk_desc *desc, int part,
fp = buf;
fp->dp.type = DEVICE_PATH_TYPE_MEDIA_DEVICE;
fp->dp.sub_type = DEVICE_PATH_SUB_TYPE_FILE_PATH;
- fp->dp.length = fpsize;
+ fp->dp.length = (u16)fpsize;
path_to_uefi(fp->str, path);
buf += fpsize;
@@ -1070,5 +1074,8 @@ efi_status_t efi_dp_from_name(const char *dev, const char *devnr,
*file = efi_dp_from_file(((!is_net && device) ? desc : NULL),
part, filename);
+ if (!file)
+ return EFI_INVALID_PARAMETER;
+
return EFI_SUCCESS;
}