summaryrefslogtreecommitdiff
path: root/apps
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 /apps
parentf9b15d951c1900806b0e37b528dd063bede7c550 (diff)
downloadrockbox-dbdcd8425a2ec2edb1c2c3ec8322723765b14da6.tar.gz
rockbox-dbdcd8425a2ec2edb1c2c3ec8322723765b14da6.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
Diffstat (limited to 'apps')
-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)
1905 } 1905 }
1906 table_history[c->dirlevel] = c->currtable; 1906 table_history[c->dirlevel] = c->currtable;
1907 extra_history[c->dirlevel] = c->currextra; 1907 extra_history[c->dirlevel] = c->currextra;
1908 c->dirlevel++; 1908
1909 if (c->dirlevel + 1 < MAX_DIR_LEVELS)
1910 {
1911 c->dirlevel++;
1912 /*DEBUGF("Tagtree depth %d\n", c->dirlevel);*/
1913 }
1914 else
1915 {
1916 DEBUGF("Tagtree depth exceeded\n");
1917 }
1909 1918
1910 /* lock buflib for possible I/O to protect dptr */ 1919 /* lock buflib for possible I/O to protect dptr */
1911 tree_lock_cache(c); 1920 tree_lock_cache(c);
@@ -2058,7 +2067,15 @@ void tagtree_exit(struct tree_context* c, bool is_visible)
2058 } 2067 }
2059 c->dirfull = false; 2068 c->dirfull = false;
2060 if (c->dirlevel > 0) 2069 if (c->dirlevel > 0)
2070 {
2061 c->dirlevel--; 2071 c->dirlevel--;
2072 /*DEBUGF("Tagtree depth %d\n", c->dirlevel);*/
2073 }
2074 else
2075 {
2076 DEBUGF("Tagtree nothing to exit\n");
2077 }
2078
2062 if (is_visible) 2079 if (is_visible)
2063 c->selected_item = selected_item_history[c->dirlevel]; 2080 c->selected_item = selected_item_history[c->dirlevel];
2064 c->currtable = table_history[c->dirlevel]; 2081 c->currtable = table_history[c->dirlevel];