summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWilliam Wilgus <wilgus.william@gmail.com>2024-08-18 13:11:59 -0400
committerWilliam Wilgus <wilgus.william@gmail.com>2024-08-20 00:34:03 -0400
commit3b040673cc638885ba7bd44b7be72994ebe7f245 (patch)
treef0452e1092a7a3399304e1b79b0c9057a68ae264
parentea0e3704a8aacf87f20ba87e3b33bc4b3966c731 (diff)
downloadrockbox-3b040673cc.tar.gz
rockbox-3b040673cc.zip
Add verification to multiboot redirect
check that a firmware file exists before we redirect to an invalid directory Change-Id: Id496fde3508158bc80f90dfb18a31ebae7229787
-rw-r--r--firmware/include/dircache_redirect.h26
1 files changed, 19 insertions, 7 deletions
diff --git a/firmware/include/dircache_redirect.h b/firmware/include/dircache_redirect.h
index ddd86c6d86..d7314cf3b1 100644
--- a/firmware/include/dircache_redirect.h
+++ b/firmware/include/dircache_redirect.h
@@ -24,6 +24,7 @@
#include "pathfuncs.h"
#include "dir.h"
#include "dircache.h"
+#include "file.h"
#if defined(HAVE_MULTIBOOT) && !defined(SIMULATOR) && !defined(BOOTLOADER)
#include "rb-loader.h"
@@ -185,22 +186,33 @@ static inline void volume_onmount_internal(IF_MV_NONVOID(int volume))
if (multiboot_is_boot_volume(IF_MV_VOL(volume)))
{
- int rtlen = get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "");
- while (rtlen > 0 && rtpath[--rtlen] == PATH_SEPCH)
- rtpath[rtlen] = '\0'; /* remove extra separators */
+ /* get the full path to the BOOTFILE
+ ie. /<0>/redirectdir/.rockbox/rockbox.ext */
+ int rtlen = get_redirect_dir(rtpath, sizeof(rtpath),
+ volume, BOOTDIR, BOOTFILE);
+
+ if (rtlen <= 0 || rtlen >= (int) sizeof(rtpath))
+ rtlen = 0; /* path too long or sprintf error */
+ else if (file_exists(rtpath))
+ {
+ rtlen = get_redirect_dir(rtpath, sizeof(rtpath), volume, "", "");
+ while (rtlen > 0 && rtpath[--rtlen] == PATH_SEPCH)
+ rtpath[rtlen] = '\0'; /* remove separators */
+ }
+ else
+ rtlen = 0; /* No BOOTFILE found */
#if 0 /*removed, causes issues with playback for now?*/
if (rtlen <= 0 || rtpath[rtlen] == VOL_END_TOK)
root_unmount_volume(volume); /* unmount so root can be hidden*/
#endif
- if (rtlen <= 0) /* Error occurred, card removed? Set root to default */
- {
+ if (rtlen <= 0 || root_mount_path(rtpath, NSITEM_CONTENTS) != 0)
+ { /* Error occurred, card removed? Set root to default */
+ boot_data_valid = false;
root_unmount_volume(volume); /* unmount so root can be hidden*/
goto standard_redirect;
}
- root_mount_path(rtpath, NSITEM_CONTENTS);
}
-
}
else
{