aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2014-04-29 11:19:50 +0100
committerMatt Fleming <matt.fleming@intel.com>2014-04-29 11:22:34 +0100
commit668ace1207f208260711a37a5b7877101eb0cd0b (patch)
treeeb7b9a9fc9698494c5a01db806bff91007579610
parenta995826f9e43f1134baea61610eafd8c173bb776 (diff)
downloadefilinux-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.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/entry.c b/entry.c
index 0aa6cdd..b2b655f 100644
--- a/entry.c
+++ b/entry.c
@@ -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;
}