From 7edc34c4ee8dc0913ea1a4ec64d3fbe6d64afc6d Mon Sep 17 00:00:00 2001 From: Javier Martinez Canillas Date: Thu, 20 Jun 2019 18:09:56 +0200 Subject: discover/grub2: Allow to separate the --id argument using a space char The GRUB menuentry command allows to separate the arguments for options using either a '=' or a ' '. The latter is the convention used when the menu entries are defined in the GRUB config file, but this is currently not supported by Petitboot. Add tests to cover both using '--id=foo' and '--id foo' as options. Signed-off-by: Javier Martinez Canillas Signed-off-by: Samuel Mendoza-Jonas --- discover/grub2/script.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'discover') diff --git a/discover/grub2/script.c b/discover/grub2/script.c index c910bf8..8a9d91d 100644 --- a/discover/grub2/script.c +++ b/discover/grub2/script.c @@ -339,9 +339,16 @@ int statement_menuentry_execute(struct grub2_script *script, * implementation to get --id= working. */ for (i = 1; i < st->argv->argc; ++i) { - if (strncmp("--id=", st->argv->argv[i], 5) == 0) { - id = st->argv->argv[i] + 5; - break; + if (strncmp("--id", st->argv->argv[i], strlen("--id")) == 0) { + if (strlen(st->argv->argv[i]) > strlen("--id=")) { + id = st->argv->argv[i] + strlen("--id="); + break; + } + + if (i + 1 < st->argv->argc) { + id = st->argv->argv[i + 1]; + break; + } } } if (st->argv->argc > 0) -- cgit v1.2.1