]> git.ozlabs.org Git - petitboot/commitdiff
ui/nc: Handle cui_opt_data with no boot option more gracefully
authorJeremy Kerr <jk@ozlabs.org>
Tue, 7 May 2013 06:36:51 +0000 (14:36 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 9 May 2013 00:47:54 +0000 (08:47 +0800)
We can currently segfault petitboot by escaping from the option editor
(before entering any details), then trying to boot the new, empty
option.

This change adds some sanity checks to prevent a segfault.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
ui/ncurses/nc-cui.c

index 342b60342ad5adc5b39f540ce89f79e096782240..167c2bb4eee4e13c996fc462ae2b56628ffe64a0 100644 (file)
@@ -109,6 +109,11 @@ static int cui_boot(struct pmenu_item *item)
        assert(cui->current == &cui->main->scr);
 
        pb_log("%s: %s\n", __func__, cod->name);
+       if (!cod->opt) {
+               pb_log("%s: missing opt?\n", __func__);
+               return -1;
+       }
+
        nc_scr_status_printf(cui->current, "Booting %s...", cod->name);
 
        def_prog_mode();