mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-09-28 23:50:26 +09:00
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>
This commit is contained in:
parent
645b5afbb8
commit
28a4fd46e7
@ -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,
|
EFI_ENTRY("%d, %p, %pD, %p, %ld, %p", boot_policy, parent_image,
|
||||||
file_path, source_buffer, source_size, image_handle);
|
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));
|
info = calloc(1, sizeof(*info));
|
||||||
|
if (!info) {
|
||||||
|
ret = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
obj = calloc(1, sizeof(*obj));
|
obj = calloc(1, sizeof(*obj));
|
||||||
|
if (!obj) {
|
||||||
|
free(info);
|
||||||
|
ret = EFI_OUT_OF_RESOURCES;
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
|
||||||
if (!source_buffer) {
|
if (!source_buffer) {
|
||||||
struct efi_device_path *dp, *fp;
|
struct efi_device_path *dp, *fp;
|
||||||
@ -1552,6 +1571,7 @@ static efi_status_t EFIAPI efi_load_image(bool boot_policy,
|
|||||||
failure:
|
failure:
|
||||||
free(info);
|
free(info);
|
||||||
efi_delete_handle(obj);
|
efi_delete_handle(obj);
|
||||||
|
error:
|
||||||
return EFI_EXIT(ret);
|
return EFI_EXIT(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user