discover/grub2: skip menuentries that don't define a boot option
authorJeremy Kerr <jk@ozlabs.org>
Fri, 24 Jan 2014 05:45:24 +0000 (13:45 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 30 Jan 2014 13:59:10 +0000 (21:59 +0800)
menuentries may perform arbitrary commands; we only want ones that
define a boot option.

This change doesn't add a boot option if we haven't seen at least a boot
image defined in the menuentry.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
discover/grub2/script.c

index 642ed2a093bf1990e234fe6c916454956871c860..3e2ee055134aad3482a50e80d94f1e5e654e83ae 100644 (file)
@@ -374,6 +374,9 @@ int statement_menuentry_execute(struct grub2_script *script,
 
        statements_execute(script, st->statements);
 
+       if (!opt->boot_image)
+               return -1;
+
        opt->option->is_default = option_is_default(script, opt, id);
 
        discover_context_add_boot_option(script->ctx, opt);