summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-06-06 10:51:06 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2024-06-06 10:53:11 -0400
commitdbdcd8425a2ec2edb1c2c3ec8322723765b14da6 (patch)
tree2cdcbbc29f54297c5d37b0ae261ffc0dd11db831
parentf9b15d951c1900806b0e37b528dd063bede7c550 (diff)
downloadrockbox-dbdcd8425a.tar.gz
rockbox-dbdcd8425a.zip
[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
-rw-r--r--apps/tagtree.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 0aa1de5673..ea2a756a46 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -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;
- 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 */
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];