diff options
author | Matt Fleming <matt.fleming@intel.com> | 2014-04-29 11:19:50 +0100 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2014-04-29 11:22:34 +0100 |
commit | 668ace1207f208260711a37a5b7877101eb0cd0b (patch) | |
tree | eb7b9a9fc9698494c5a01db806bff91007579610 | |
parent | a995826f9e43f1134baea61610eafd8c173bb776 (diff) | |
download | efilinux-668ace1207f208260711a37a5b7877101eb0cd0b.tar.gz |
efilinux: Make option parsing more robust
Thomas reports that efilinux hangs when executed via gummiboot. The
reason being that efilinux expects the executable name to be prepended
to the beginning of the LoadOptions string.
This behaviour isn't required by the UEFI spec, so make the options
parsing more robust to handle either case.
Reported-by: Thomas Bächler <thomas@archlinux.org>
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | entry.c | 15 |
1 files changed, 12 insertions, 3 deletions
@@ -430,9 +430,18 @@ efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *_table) options = info->LoadOptions; options_size = info->LoadOptionsSize; - /* Skip the first word, that's our name. */ - for (i = 0; i < options_size && options[i] != ' '; i++) - ; + /* + * Skip the first word, that's probably our name. Stop + * when we hit a word delimiter (' ') or the start of an + * efilinux argument ('-'). + */ + i = 0; + while (i < options_size) { + if (options[i] == ' ' || options[i] == '-') + break; + i++; + } + options = &options[i]; options_size -= i; } |