plugins: properties: fix stack overflow in db

rockbox-gerrit-noreply--- via rockbox-cvs <[email protected]> Thu, 28 May 2026 19:58:22 -0400
Newsgroups gmane.comp.systems.archos.rockbox.cvs
Message-ID <[email protected]>
commit 9f20c45a5ed1552d55b5657461cb11ec8e303b80
Author: Christian Soffke <[email protected]>
Date:   Thu May 28 22:50:33 2026 +0200

    plugins: properties: fix stack overflow in db
    
    Stack overflow in splash_progress called from
    tagtree_subentries_do_action with stack protector
    enabled on mips
    
    Change-Id: Ia71e0493e279af0531ae792d41442198555664f6

diff --git a/apps/plugin.c b/apps/plugin.c
index 151fd4be4a..282b0dcd51 100644
--- a/apps/plugin.c
+++ b/apps/plugin.c
@@ -353,6 +353,7 @@ static const struct plugin_api rockbox_api = {
     gui_synclist_del_item,
     gui_synclist_do_button,
     gui_synclist_set_title,
+    gui_synclist_scroll_stop,
     gui_syncyesno_run,
     simplelist_info_init,
     simplelist_show_list,
@@ -488,6 +489,7 @@ static const struct plugin_api rockbox_api = {
     talk_force_enqueue_next,
 
     /* kernel/ system */
+    panicf,
 #if defined(ARM_NEED_DIV0)
     __div0,
 #endif
@@ -562,7 +564,9 @@ static const struct plugin_api rockbox_api = {
     __cyg_profile_func_exit,
 #endif
     add_event,
+    add_event_ex,
     remove_event,
+    remove_event_ex,
     send_event,
 
 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
@@ -578,6 +582,7 @@ static const struct plugin_api rockbox_api = {
     vsnprintf,
     vuprintf,
     strcpy,
+    strncpy,
     strlcpy,
     strlen,
     strrchr,
@@ -711,7 +716,7 @@ static const struct plugin_api rockbox_api = {
     tagcache_fill_tags,
 #endif
 #endif
-    tagtree_subentries_do_action,
+    tagtree_entries_iterate,
 #endif /* HAVE_TAGCACHE */
 
 #ifdef HAVE_ALBUMART
@@ -871,11 +876,6 @@ static const struct plugin_api rockbox_api = {
 
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
-    panicf,
-    gui_synclist_scroll_stop,
-    add_event_ex,
-    remove_event_ex,
-    strncpy,
 };
 
 static int plugin_buffer_handle;
diff --git a/apps/plugin.h b/apps/plugin.h
index d20857302d..73262cd8eb 100644
--- a/apps/plugin.h
+++ b/apps/plugin.h
@@ -180,7 +180,7 @@ int plugin_open(const char *plugin, const char *parameter);
  * when this happens please take the opportunity to sort in
  * any new functions "waiting" at the end of the list.
  */
-#define PLUGIN_API_VERSION 282
+#define PLUGIN_API_VERSION 283
 
 /* 239 Marks the removal of ARCHOS HWCODEC and CHARCELL */
 
@@ -413,6 +413,7 @@ struct plugin_api {
     bool (*gui_synclist_do_button)(struct gui_synclist * lists, int *action);
     void (*gui_synclist_set_title)(struct gui_synclist *lists, const char* title,
                                    enum themable_icons icon);
+    void (*gui_synclist_scroll_stop)(struct gui_synclist *lists);
     enum yesno_res (*gui_syncyesno_run)(const struct text_message * main_message,
                                         const struct text_message * yes_message,
                                         const struct text_message * no_message);
@@ -568,6 +569,7 @@ struct plugin_api {
     void (*talk_force_enqueue_next)(void);
 
     /* kernel/ system */
+    void (*panicf)(const char *msg, ...);
 #if defined(ARM_NEED_DIV0)
     void (*__div0)(void);
 #endif
@@ -654,7 +656,17 @@ struct plugin_api {
 #endif
     /* event api */
     bool (*add_event)(unsigned short id, void (*handler)(unsigned short id, void *data));
+    bool (*add_event_ex)(unsigned short id, bool oneshot,
+                         void (*handler)(unsigned short id,
+                                         void *event_data,
+                                         void *user_data),
+                         void *user_data);
     void (*remove_event)(unsigned short id, void (*handler)(unsigned short id, void *data));
+    void (*remove_event_ex)(unsigned short id,
+                            void (*handler)(unsigned short id,
+                                            void *event_data,
+                                            void *user_data),
+                            void *user_data);
     void (*send_event)(unsigned short id, void *data);
 
 #if (CONFIG_PLATFORM & PLATFORM_HOSTED)
@@ -671,6 +683,7 @@ struct plugin_api {
     int (*vsnprintf)(char *buf, size_t size, const char *fmt, va_list ap);
     int (*vuprintf)(vuprintf_push_cb push, void *userp, const char *fmt, va_list ap);
     char* (*strcpy)(char *dst, const char *src);
+    char* (*strncpy)(char * dst, const char * src, size_t count);
     size_t (*strlcpy)(char *dst, const char *src, size_t length);
     size_t (*strlen)(const char *str);
     char * (*strrchr)(const char *s, int c);
@@ -829,7 +842,8 @@ struct plugin_api {
     bool (*tagcache_fill_tags)(struct mp3entry *id3, const char *filename);
 #endif
 #endif
-    bool (*tagtree_subentries_do_action)(bool (*action_cb)(const char *file_name));
+    bool (*tagtree_entries_iterate)(bool (*action_cb)(const char *file_name),
+                                    char *buf, size_t buf_sz);
 #endif /* HAVE_TAGCACHE */
 
 #ifdef HAVE_ALBUMART
@@ -1025,19 +1039,6 @@ struct plugin_api {
 
     /* new stuff at the end, sort into place next time
        the API gets incompatible */
-    void (*panicf)(const char *msg, ...);
-    void (*gui_synclist_scroll_stop)(struct gui_synclist *lists);
-    bool (*add_event_ex)(unsigned short id, bool oneshot,
-                         void (*handler)(unsigned short id,
-                                         void *event_data,
-                                         void *user_data),
-                         void *user_data);
-    void (*remove_event_ex)(unsigned short id,
-                            void (*handler)(unsigned short id,
-                                            void *event_data,
-                                            void *user_data),
-                            void *user_data);
-    char* (*strncpy)(char * dst, const char * src, size_t count);
 };
 
 /* plugin header */
diff --git a/apps/plugins/properties.c b/apps/plugins/properties.c
index f61f8bcabb..00d293cfb9 100644
--- a/apps/plugins/properties.c
+++ b/apps/plugins/properties.c
@@ -307,7 +307,8 @@ static bool assemble_track_info(const char *filename, struct dir_stats *stats)
         return false;
 #ifdef HAVE_TAGCACHE
     else if (props_type == PROPS_MUL_ID3 &&
-             !rb->tagtree_subentries_do_action(&mul_id3_add))
+             !rb->tagtree_entries_iterate(&mul_id3_add, str_filename,
+                                                 sizeof str_filename))
         return false;
 #endif
 
diff --git a/apps/tagtree.c b/apps/tagtree.c
index 67ff646205..7b8af2618e 100644
--- a/apps/tagtree.c
+++ b/apps/tagtree.c
@@ -2649,17 +2649,17 @@ static bool tagtree_insert_selection(int position, bool queue,
     return ret;
 }
 
-/* Execute action_cb for all subentries of the current table's
+/* Execute action_cb for all entries of the current table's
  * selected item, handing over each entry's filename in the
  * callback function parameter. Parameter will be NULL for
  * entries whose filename couldn't be retrieved.
  */
-bool tagtree_subentries_do_action(bool (*action_cb)(const char *file_name))
+bool tagtree_entries_iterate(bool (*action_cb)(const char *file_name),
+                             char* buf, size_t buf_sz)
 {
     struct tagcache_search tcs;
     int i, n;
     unsigned long last_tick;
-    char buf[MAX_PATH];
     int ret = true;
     int dirlevel = tc->dirlevel;
     int selected_item = tc->selected_item;
@@ -2685,7 +2685,7 @@ bool tagtree_subentries_do_action(bool (*action_cb)(const char *file_name))
             }
 
             if (!action_cb(tagcache_retrieve(&tcs, tagtree_get_entry(tc, i)->extraseek,
-                                             tcs.type, buf, sizeof buf) ? buf : NULL))
+                                             tcs.type, buf, buf_sz) ? buf : NULL))
             {
                 ret = false;
                 break;
diff --git a/apps/tagtree.h b/apps/tagtree.h
index a57a5c2f80..7134f827a0 100644
--- a/apps/tagtree.h
+++ b/apps/tagtree.h
@@ -47,7 +47,8 @@ int tagtree_get_icon(struct tree_context* c);
 int tagtree_get_filename(struct tree_context* c, char *buf, int buflen);
 int tagtree_get_custom_action(struct tree_context* c);
 bool tagtree_get_subentry_filename(char *buf, size_t bufsize);
-bool tagtree_subentries_do_action(bool (*action_cb)(const char *file_name));
+bool tagtree_entries_iterate(bool (*action_cb)(const char *file_name),
+                             char *buf, size_t buf_sz);
 
 #endif
 #endif
diff --git a/docs/PLUGIN_API b/docs/PLUGIN_API
index 01acbe2181..faf158a2f3 100644
--- a/docs/PLUGIN_API
+++ b/docs/PLUGIN_API
@@ -2765,7 +2765,7 @@ void tagcache_search_set_uniqbuf(struct tagcache_search *tcs, void *buffer, long
     \param length
     \description
 
-bool tagtree_subentries_do_action(bool (*action_cb)(const char *file_name))
+bool tagtree_entries_iterate(bool (*action_cb)(const char *file_name), char* buf, size_t buf_sz)
     \group metadata
     \conditions (defined(HAVE_TAGCACHE))
     \param action_cb
-- 
rockbox-cvs mailing list
[email protected]
https://lists.haxx.se/mailman/listinfo/rockbox-cvs