From: Jeremy Kerr Date: Tue, 7 May 2013 06:36:51 +0000 (+0800) Subject: ui/nc: Handle cui_opt_data with no boot option more gracefully X-Git-Tag: v1.0.0~643 X-Git-Url: http://git.ozlabs.org/?p=petitboot;a=commitdiff_plain;h=038cb53fa8e19592b9c7021176fda194799f1d51;hp=488fa97839822949f855de1efa3cf47756b7f72b ui/nc: Handle cui_opt_data with no boot option more gracefully 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 --- diff --git a/ui/ncurses/nc-cui.c b/ui/ncurses/nc-cui.c index 342b603..167c2bb 100644 --- a/ui/ncurses/nc-cui.c +++ b/ui/ncurses/nc-cui.c @@ -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();