]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[menu] Truncate menu title when necessary
authorChristian Hesse <list@eworm.de>
Tue, 3 Jul 2012 13:12:47 +0000 (14:12 +0100)
committerMichael Brown <mcb30@ipxe.org>
Tue, 3 Jul 2012 13:12:47 +0000 (14:12 +0100)
Modified-by: Michael Brown <mcb30@ipxe.org>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/hci/tui/menu_ui.c

index 616256228a06cb981ea8be528532c6ff675451d9..e92500996127bdf055f80f7a778ce9bae28e5054 100644 (file)
@@ -307,6 +307,7 @@ int show_menu ( struct menu *menu, unsigned int timeout_ms,
                const char *select, struct menu_item **selected ) {
        struct menu_item *item;
        struct menu_ui ui;
+       char buf[ MENU_COLS + 1 /* NUL */ ];
        int labelled_count = 0;
        int rc;
 
@@ -348,8 +349,8 @@ int show_menu ( struct menu *menu, unsigned int timeout_ms,
 
        /* Draw initial content */
        attron ( A_BOLD );
-       mvprintw ( TITLE_ROW, ( ( COLS - strlen ( ui.menu->title ) ) / 2 ),
-                  "%s", ui.menu->title );
+       snprintf ( buf, sizeof ( buf ), "%s", ui.menu->title );
+       mvprintw ( TITLE_ROW, ( ( COLS - strlen ( buf ) ) / 2 ), "%s", buf );
        attroff ( A_BOLD );
        draw_menu_items ( &ui );
        draw_menu_item ( &ui, ui.selected );