summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-02-02 16:50:13 +1100
committerSamuel Mendoza-Jonas <sam.mj@au1.ibm.com>2015-02-16 14:21:36 +1100
commit7b67c329067af30ffd2a1dd44cd938a7ee55af56 (patch)
tree436a3463883de30b89dc3f4b1319c2574b002cbf
parent900412ec49f30fbb7872a5ff38538a19c17e20a2 (diff)
downloadpetitboot-7b67c329067af30ffd2a1dd44cd938a7ee55af56.zip
petitboot-7b67c329067af30ffd2a1dd44cd938a7ee55af56.tar.gz
ui/ncurses: Prevent creation of empty boot entry
A boot option requires an image path at minimum. If an option is created without an image, trying to edit the resulting user item causes a segfault. Prevent the user from creating a boot option without at least an image path. Signed-off-by: Samuel Mendoza-Jonas <sam.mj@au1.ibm.com>
-rw-r--r--ui/ncurses/nc-boot-editor.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/ui/ncurses/nc-boot-editor.c b/ui/ncurses/nc-boot-editor.c
index 409e638..f78da56 100644
--- a/ui/ncurses/nc-boot-editor.c
+++ b/ui/ncurses/nc-boot-editor.c
@@ -173,6 +173,10 @@ static struct pb_boot_data *boot_editor_prepare_data(
s = widget_textbox_get_value(boot_editor->widgets.image_f);
bd->image = conditional_prefix(bd, prefix, s);
+ if (!bd->image) {
+ talloc_free(bd);
+ return NULL;
+ }
s = widget_textbox_get_value(boot_editor->widgets.initrd_f);
bd->initrd = conditional_prefix(bd, prefix, s);
@@ -216,6 +220,11 @@ static void boot_editor_process_key(struct nc_scr *scr, int key)
case STATE_SAVE:
item = boot_editor->item;
bd = boot_editor_prepare_data(boot_editor);
+ if (!bd) {
+ /* Incomplete entry */
+ boot_editor->state = STATE_EDIT;
+ break;
+ }
/* fall through */
case STATE_CANCEL:
boot_editor->on_exit(boot_editor->cui, item, bd);
OpenPOWER on IntegriCloud