sd-boot: stub: check LoadOptions contains data (#5467)

With some UEFI shells LoadOptionsSize is reported being > 0
but the corresponding LoadOptions does not contain any data
(the first element has value 0).

When that happens, the stub feature that allows .cmdline to be
replaced by what's in LoadOptions ends up copying nothing/random
data to the kernel cmdline resulting in different kinds of boot
problems.

To fix this, add a check to see if LoadOptions contains data
before replacing the .cmdline.

Signed-off-by: Mikko Ylinen <mikko.ylinen@linux.intel.com>
This commit is contained in:
Mikko Ylinen 2017-02-27 21:03:07 +02:00 committed by Lennart Poettering
parent 3c3fff44b2
commit 293b167349
1 changed files with 1 additions and 1 deletions

View File

@ -87,7 +87,7 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *sys_table) {
cmdline_len = szs[0];
/* if we are not in secure boot mode, accept a custom command line and replace the built-in one */
if (!secure && loaded_image->LoadOptionsSize > 0) {
if (!secure && loaded_image->LoadOptionsSize > 0 && *(CHAR16 *)loaded_image->LoadOptions != 0) {
CHAR16 *options;
CHAR8 *line;
UINTN i;