efi: properly terminate filepath with NULL in chainloader
EFI File Path Media Device Path is defined as NULL terminated string; but chainloader built file paths without final NULL. This caused error with Secure Boot and Linux Foundation PreLoader on Acer with InsydeH20 BIOS. Apparently firmware failed verification with EFI_INVALID_PARAMETER which is considered fatal error by PreLoader. Reported and tested by Giovanni Santini <itachi.sama.amaterasu@gmail.com>
This commit is contained in:
parent
a3e9da054d
commit
ce95549cc5
1 changed files with 5 additions and 1 deletions
|
@ -122,6 +122,8 @@ copy_file_path (grub_efi_file_path_device_path_t *fp,
|
||||||
if (*p == '/')
|
if (*p == '/')
|
||||||
*p = '\\';
|
*p = '\\';
|
||||||
|
|
||||||
|
/* File Path is NULL terminated */
|
||||||
|
fp->path_name[size++] = '\0';
|
||||||
fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp);
|
fp->header.length = size * sizeof (grub_efi_char16_t) + sizeof (*fp);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,8 +158,10 @@ make_file_path (grub_efi_device_path_t *dp, const char *filename)
|
||||||
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
|
d = GRUB_EFI_NEXT_DEVICE_PATH (d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* File Path is NULL terminated. Allocate space for 2 extra characters */
|
||||||
|
/* FIXME why we split path in two components? */
|
||||||
file_path = grub_malloc (size
|
file_path = grub_malloc (size
|
||||||
+ ((grub_strlen (dir_start) + 1)
|
+ ((grub_strlen (dir_start) + 2)
|
||||||
* GRUB_MAX_UTF16_PER_UTF8
|
* GRUB_MAX_UTF16_PER_UTF8
|
||||||
* sizeof (grub_efi_char16_t))
|
* sizeof (grub_efi_char16_t))
|
||||||
+ sizeof (grub_efi_file_path_device_path_t) * 2);
|
+ sizeof (grub_efi_file_path_device_path_t) * 2);
|
||||||
|
|
Loading…
Reference in a new issue