From e5fc7dc71c25b483b353f836c0b096e1ec3cb41f Mon Sep 17 00:00:00 2001 From: Maschell Date: Sat, 9 Jan 2021 18:50:57 +0100 Subject: [PATCH] Check for magic value "WUHB" --- include/romfs_dev.h | 3 ++- source/romfs_dev.c | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/include/romfs_dev.h b/include/romfs_dev.h index 39bbed0..6f555a6 100644 --- a/include/romfs_dev.h +++ b/include/romfs_dev.h @@ -13,7 +13,8 @@ /// RomFS header. typedef struct { - uint64_t headerSize; ///< Size of the header. + uint32_t headerMagic; ///< Magic value. + uint32_t headerSize; ///< Size of the header. uint64_t dirHashTableOff; ///< Offset of the directory hash table. uint64_t dirHashTableSize; ///< Size of the directory hash table. uint64_t dirTableOff; ///< Offset of the directory table. diff --git a/source/romfs_dev.c b/source/romfs_dev.c index 8e90f70..35e8242 100644 --- a/source/romfs_dev.c +++ b/source/romfs_dev.c @@ -286,6 +286,10 @@ int32_t romfsMountCommon(const char *name, romfs_mount *mount) { goto fail_io; } + if (memcmp(&mount->header.headerMagic, "WUHB", sizeof(mount->header.headerMagic)) != 0) { + goto fail_io; + } + if (mount->header.headerSize != 0x50) { goto fail_io; }