menu.c submenu items should be limited to MAX_MENU_SUBITEMS

maybe someone is checking somewhere but pretty sure the error message is a
buffer overflow

Change-Id: I3b95db12bbbd4631223bbbbe540beb2d0dd984c6
This commit is contained in:
William Wilgus 2021-04-07 12:15:20 -04:00 committed by Solomon Peachy
parent da542020c4
commit c5cf15ed02

View file

@ -180,7 +180,8 @@ static void init_menu_lists(const struct menu_item_ex *menu,
struct gui_synclist *lists, int selected, bool callback,
struct viewport parent[NB_SCREENS])
{
int i, count = MENU_GET_COUNT(menu->flags);
int i;
int count = MIN(MENU_GET_COUNT(menu->flags), MAX_MENU_SUBITEMS);
int type = (menu->flags&MENU_TYPE_MASK);
menu_callback_type menu_callback = NULL;
int icon;
@ -210,6 +211,7 @@ static void init_menu_lists(const struct menu_item_ex *menu,
current_subitems_count++;
}
}
current_submenus_menu = (struct menu_item_ex *)menu;
gui_synclist_init(lists,get_menu_item_name,(void*)menu,false,1, parent);