[U-Boot,1/1] efi_loader: check parameters EFI_FILE_PROTOCOL.GetInfo()
diff mbox series

Message ID 20190911170334.3197-1-xypron.glpk@gmx.de
State Accepted, archived
Delegated to: Heinrich Schuchardt
Headers show
Series
  • [U-Boot,1/1] efi_loader: check parameters EFI_FILE_PROTOCOL.GetInfo()
Related show

Commit Message

Heinrich Schuchardt Sept. 11, 2019, 5:03 p.m. UTC
Check the parameters of EFI_FILE_PROTOCOL.GetInfo() to avoid possible NULL
dereference.

Check the buffer size for EFI_FILE_SYSTEM_INFO.

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/efi_loader/efi_file.c | 6 ++++++
 1 file changed, 6 insertions(+)

--
2.23.0

Patch
diff mbox series

diff --git a/lib/efi_loader/efi_file.c b/lib/efi_loader/efi_file.c
index 2f03ae71fc..b79dc5fd29 100644
--- a/lib/efi_loader/efi_file.c
+++ b/lib/efi_loader/efi_file.c
@@ -596,6 +596,12 @@  static efi_status_t EFIAPI efi_file_getinfo(struct efi_file_handle *file,

 	EFI_ENTRY("%p, %pUl, %p, %p", file, info_type, buffer_size, buffer);

+	if (!file || !info_type || !buffer_size ||
+	    (*buffer_size && !buffer)) {
+		ret = EFI_INVALID_PARAMETER;
+		goto error;
+	}
+
 	if (!guidcmp(info_type, &efi_file_info_guid)) {
 		struct efi_file_info *info = buffer;
 		char *filename = basename(fh);