Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove incorrect ExeFS header hash validation. #137

Merged
merged 1 commit into from Mar 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ctrtool/deps/libnintendo-n3ds/src/ExeFsSnapshotGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ ntd::n3ds::ExeFsSnapshotGenerator::ExeFsSnapshotGenerator(const std::shared_ptr<
stream->seek(0, tc::io::SeekOrigin::Begin);
stream->read((byte_t*)(&hdr), sizeof(ntd::n3ds::ExeFsHeader));

if (hdr.file_table[0].name[0] == 0 || hdr.file_table[0].offset.unwrap() != 0 || hdr.hash_table[ntd::n3ds::ExeFsHeader::kFileNum - 1][0] == 0)
if (hdr.file_table[0].name[0] == 0 || hdr.file_table[0].offset.unwrap() != 0)
{
throw tc::ArgumentOutOfRangeException("ntd::n3ds::ExeFsSnapshotGenerator", "ExeFsHeader is corrupted (Bad first entry).");
}
Expand Down Expand Up @@ -119,4 +119,4 @@ ntd::n3ds::ExeFsSnapshotGenerator::ExeFsSnapshotGenerator(const std::shared_ptr<
cur_dir->dir_listing.file_list.push_back(section[i].name);
}
}
}
}
4 changes: 2 additions & 2 deletions ctrtool/src/ExeFsProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void ctrtool::ExeFsProcess::importHeader()
mInputStream->read((byte_t*)&mHeader, sizeof(ntd::n3ds::ExeFsHeader));

// do some simple checks to verify if this is an EXEFS header
if (mHeader.file_table[0].name[0] == 0 || mHeader.file_table[0].offset.unwrap() != 0 || mHeader.hash_table[ntd::n3ds::ExeFsHeader::kFileNum - 1][0] == 0)
if (mHeader.file_table[0].name[0] == 0 || mHeader.file_table[0].offset.unwrap() != 0)
{
throw tc::ArgumentOutOfRangeException(mModuleLabel, "ExeFsHeader is corrupted (Bad first entry).");
}
Expand Down Expand Up @@ -281,4 +281,4 @@ std::string ctrtool::ExeFsProcess::getValidString(byte_t validstate)
}

return ret_str;
}
}
3 changes: 1 addition & 2 deletions ctrtool/src/NcchProcess.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -489,8 +489,7 @@ void ctrtool::NcchProcess::determineRegionEncryption()

// quick header validation
if (exefs_hdr.file_table[0].name[0] == 0 ||
exefs_hdr.file_table[0].offset.unwrap() != 0 ||
exefs_hdr.getFileHash(0)->operator[](0) == 0)
exefs_hdr.file_table[0].offset.unwrap() != 0)
{
throw tc::ArgumentOutOfRangeException(mModuleLabel, "ExeFsHeader is corrupted (Bad first entry).");
}
Expand Down