]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[menu] Prevent character code zero from acting as a shortcut key
authorMichael Brown <mcb30@ipxe.org>
Wed, 6 Mar 2013 14:41:46 +0000 (14:41 +0000)
committerMichael Brown <mcb30@ipxe.org>
Wed, 6 Mar 2013 14:41:46 +0000 (14:41 +0000)
Unrecognised keys may be returned by getkey() as character code zero,
which currently matches against the first menu item with no shortcut
key defined.

Prevent this unintended behaviour by explicitly checking that the menu
item has a defined shortcut key.

Reported-by: Ján ONDREJ (SAL) <ondrejj@salstar.sk>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/hci/tui/menu_ui.c

index dfa1d2e76cec6075705fc7a122d0d20c99eafec6..497407953c8398a2a9cd81b3a1dd9890daa47ea6 100644 (file)
@@ -247,7 +247,8 @@ static int menu_loop ( struct menu_ui *ui, struct menu_item **selected ) {
                                i = 0;
                                list_for_each_entry ( item, &ui->menu->items,
                                                      list ) {
-                                       if ( item->shortcut == key ) {
+                                       if ( item->shortcut &&
+                                            ( item->shortcut == key ) ) {
                                                ui->selected = i;
                                                chosen = 1;
                                                break;