diff options
author | Heinrich Schuchardt <xypron.glpk@gmx.de> | 2018-03-07 02:40:51 +0100 |
---|---|---|
committer | Alexander Graf <agraf@suse.de> | 2018-04-04 11:00:06 +0200 |
commit | 28a4fd46e7c6507d788677406a8bd385e0cb35eb (patch) | |
tree | 26cdee4b59aa710b18d480b8d2287b26ebdb3e46 /lib/efi_loader | |
parent | 645b5afbb8215b3386cd6fc2dc3119bd68e4c760 (diff) | |
download | u-boot-28a4fd46e7c6507d788677406a8bd385e0cb35eb.tar.gz |
efi_loader: parameter checks for LoadImage
Add parameter checks in efi_load_image().
Check memory allocation is successful in efi_load_image().
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Signed-off-by: Alexander Graf <agraf@suse.de>
Diffstat (limited to 'lib/efi_loader')
-rw-r--r-- | lib/efi_loader/efi_boottime.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/efi_loader/efi_boottime.c b/lib/efi_loader/efi_boottime.c index 66e26fd63a..8892c86f41 100644 --- a/lib/efi_loader/efi_boottime.c +++ b/lib/efi_loader/efi_boottime.c @@ -1515,8 +1515,27 @@ static efi_status_t EFIAPI efi_load_image(bool boot_policy, EFI_ENTRY("%d, %p, %pD, %p, %ld, %p", boot_policy, parent_image, file_path, source_buffer, source_size, image_handle); + if (!image_handle || !parent_image) { + ret = EFI_INVALID_PARAMETER; + goto error; + } + + if (!source_buffer && !file_path) { + ret = EFI_NOT_FOUND; + goto error; + } + info = calloc(1, sizeof(*info)); + if (!info) { + ret = EFI_OUT_OF_RESOURCES; + goto error; + } obj = calloc(1, sizeof(*obj)); + if (!obj) { + free(info); + ret = EFI_OUT_OF_RESOURCES; + goto error; + } if (!source_buffer) { struct efi_device_path *dp, *fp; @@ -1552,6 +1571,7 @@ static efi_status_t EFIAPI efi_load_image(bool boot_policy, failure: free(info); efi_delete_handle(obj); +error: return EFI_EXIT(ret); } |