1
0
Fork 0
forked from len0rd/rockbox

[coverity] tagtree.c tagtree_exit() ensure dirlevel is within bounds

max I could get was 5 with the default tagnav cfg
but we allow user code too so might be possible to exceed the depth

Change-Id: Icf37916400b464be4f75a723d64a71cd6c4be1fb
This commit is contained in:
William Wilgus 2024-06-06 10:51:06 -04:00
parent f9b15d951c
commit dbdcd8425a

View file

@ -1905,7 +1905,16 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
}
table_history[c->dirlevel] = c->currtable;
extra_history[c->dirlevel] = c->currextra;
if (c->dirlevel + 1 < MAX_DIR_LEVELS)
{
c->dirlevel++;
/*DEBUGF("Tagtree depth %d\n", c->dirlevel);*/
}
else
{
DEBUGF("Tagtree depth exceeded\n");
}
/* lock buflib for possible I/O to protect dptr */
tree_lock_cache(c);
@ -2058,7 +2067,15 @@ void tagtree_exit(struct tree_context* c, bool is_visible)
}
c->dirfull = false;
if (c->dirlevel > 0)
{
c->dirlevel--;
/*DEBUGF("Tagtree depth %d\n", c->dirlevel);*/
}
else
{
DEBUGF("Tagtree nothing to exit\n");
}
if (is_visible)
c->selected_item = selected_item_history[c->dirlevel];
c->currtable = table_history[c->dirlevel];