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:
parent
f9b15d951c
commit
dbdcd8425a
1 changed files with 18 additions and 1 deletions
|
|
@ -1905,7 +1905,16 @@ int tagtree_enter(struct tree_context* c, bool is_visible)
|
||||||
}
|
}
|
||||||
table_history[c->dirlevel] = c->currtable;
|
table_history[c->dirlevel] = c->currtable;
|
||||||
extra_history[c->dirlevel] = c->currextra;
|
extra_history[c->dirlevel] = c->currextra;
|
||||||
c->dirlevel++;
|
|
||||||
|
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 */
|
/* lock buflib for possible I/O to protect dptr */
|
||||||
tree_lock_cache(c);
|
tree_lock_cache(c);
|
||||||
|
|
@ -2058,7 +2067,15 @@ void tagtree_exit(struct tree_context* c, bool is_visible)
|
||||||
}
|
}
|
||||||
c->dirfull = false;
|
c->dirfull = false;
|
||||||
if (c->dirlevel > 0)
|
if (c->dirlevel > 0)
|
||||||
|
{
|
||||||
c->dirlevel--;
|
c->dirlevel--;
|
||||||
|
/*DEBUGF("Tagtree depth %d\n", c->dirlevel);*/
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DEBUGF("Tagtree nothing to exit\n");
|
||||||
|
}
|
||||||
|
|
||||||
if (is_visible)
|
if (is_visible)
|
||||||
c->selected_item = selected_item_history[c->dirlevel];
|
c->selected_item = selected_item_history[c->dirlevel];
|
||||||
c->currtable = table_history[c->dirlevel];
|
c->currtable = table_history[c->dirlevel];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue