Fix bug in detecting corrupt RomFs.

This commit is contained in:
jakcron 2021-10-03 10:56:55 +08:00
parent 41fee26d1f
commit 5670cb7e16
2 changed files with 8 additions and 4 deletions

@ -1 +1 @@
Subproject commit a4bef5a52859625027f75b71d802b1a53af18534
Subproject commit 02a5acb78bfa55edfeebcc42b4591b3d43424575

View file

@ -83,10 +83,10 @@ void nstool::RomfsProcess::importHeader()
mFile->seek(0, tc::io::SeekOrigin::Begin);
mFile->read((byte_t*)&mRomfsHeader, sizeof(mRomfsHeader));
if (mRomfsHeader.header_size.unwrap() != sizeof(nn::hac::sRomfsHeader) ||
mRomfsHeader.dir_hash_bucket.offset.unwrap() != sizeof(nn::hac::sRomfsHeader) ||
mRomfsHeader.dir_entry.offset.unwrap() != (mRomfsHeader.dir_hash_bucket.offset.unwrap() + mRomfsHeader.dir_hash_bucket.size.unwrap()) ||
mRomfsHeader.data_offset.unwrap() != align<int64_t>(mRomfsHeader.header_size.unwrap(), nn::hac::romfs::kRomfsHeaderAlign))
{
throw tc::ArgumentOutOfRangeException("nn::hac::RomFsMetaGenerator", "Corrupt RomFs: RomFsHeader is corrupted.");
throw tc::ArgumentOutOfRangeException(mModuleName, "Corrupt RomFs: RomFsHeader is corrupted.");
}
// get dir entry ptr
@ -105,7 +105,11 @@ void nstool::RomfsProcess::importHeader()
{
uint32_t total_size = sizeof(nn::hac::sRomfsDirEntry) + align<uint32_t>(((nn::hac::sRomfsDirEntry*)(dir_entry_table.data() + v_addr))->name_size.unwrap(), 4);
mDirNum += 1;
// don't count root directory
if (v_addr != 0)
{
mDirNum += 1;
}
v_addr += total_size;
}