mirror of
https://git.suyu.dev/suyu/suyu.git
synced 2024-12-23 17:00:57 +01:00
loader/nso: Check if read succeeded in IdentifyFile() before checking magic value
We should always assume the filesystem is volatile and check each IO operation. While we're at it reorganize checks so that early-out errors are near one another.
This commit is contained in:
parent
758c357868
commit
9b22f856c2
1 changed files with 7 additions and 5 deletions
|
@ -55,15 +55,17 @@ AppLoader_NSO::AppLoader_NSO(FileSys::VirtualFile file) : AppLoader(std::move(fi
|
|||
|
||||
FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) {
|
||||
u32 magic = 0;
|
||||
file->ReadObject(&magic);
|
||||
|
||||
if (Common::MakeMagic('N', 'S', 'O', '0') == magic) {
|
||||
return FileType::NSO;
|
||||
if (file->ReadObject(&magic) != sizeof(magic)) {
|
||||
return FileType::Error;
|
||||
}
|
||||
|
||||
if (Common::MakeMagic('N', 'S', 'O', '0') != magic) {
|
||||
return FileType::Error;
|
||||
}
|
||||
|
||||
return FileType::NSO;
|
||||
}
|
||||
|
||||
static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data,
|
||||
const NsoSegmentHeader& header) {
|
||||
std::vector<u8> uncompressed_data;
|
||||
|
|
Loading…
Reference in a new issue