Rockbox open source high quality audio player as a Music Player Daemon
mpris rockbox mpd libadwaita audio rust zig deno
2
fork

Configure Feed

Select the types of activity you want to include in your feed.

[bugfix] tree.c rockbox_browse dirfilter use after free, set_current_file_ex

rockbox_browse() set its own *dirfilter and then may neglect to restore it

set_current_file_ex()
can take a unified path and file or separate path and file

only issue is when you send a folder and don't have the final slash
its then interpreted as a file and current file is set to it
meanwhile path is split and you end up in the parent dir

instead if filename is null check if path points to a directory
if dir_exists(path) then we will use it as is and set filename to ""

Change-Id: I6beaa91141c1a4025cdfac5d6ba426137146c212

authored by

William Wilgus and committed by
William Wilgus
f3a858e1 3c9233e9

+5 -2
+5 -2
apps/tree.c
··· 609 609 return; 610 610 #endif 611 611 612 - if (!filename) /* path and filename supplied combined */ 612 + if (!filename && !dir_exists(path)) /* path and filename supplied combined */ 613 613 { 614 614 /* separate directory from filename */ 615 615 /* gets the directory's name and put it into tc.currdir */ ··· 628 628 } 629 629 else /* path and filename came in separate ensure an ending '/' */ 630 630 { 631 + if (!filename) 632 + filename = ""; 631 633 char *end_p = strmemccpy(tc.currdir, path, MAX_PATH); 632 634 size_t endpos = end_p - tc.currdir; 633 635 if (endpos < MAX_PATH) ··· 1053 1055 if (backup_count >= 0) 1054 1056 backups[backup_count] = tc; 1055 1057 backup_count++; 1056 - 1058 + int *prev_dirfilter = tc.dirfilter; 1057 1059 tc.dirfilter = &dirfilter; 1058 1060 tc.sort_dir = global_settings.sort_dir; 1059 1061 ··· 1110 1112 } 1111 1113 1112 1114 tc.is_browsing = false; 1115 + tc.dirfilter = prev_dirfilter; /* Bugfix restore dirfilter*/ 1113 1116 1114 1117 backup_count--; 1115 1118 if (backup_count >= 0)