efi_loader: check parameters EFI_FILE_PROTOCOL.GetInfo()
authorHeinrich Schuchardt <xypron.glpk@gmx.de>
Sun, 8 Sep 2019 08:45:31 +0000 (10:45 +0200)
committerHeinrich Schuchardt <xypron.glpk@gmx.de>
Mon, 9 Sep 2019 13:21:09 +0000 (15:21 +0200)
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

index 3a108c6bf742ce7574159f07dc4f21e4387ab552..71582e5149ec720c207500cb036c8c38a9b1b72c 100644 (file)
@@ -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);