Browse Source
Merge pull request #718 from lioncash/read
loader/nso: Check if read succeeded in IdentifyFile() before checking magic value
pull/15/merge
bunnei
8 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with
6 additions and
4 deletions
-
src/core/loader/nso.cpp
|
|
|
@ -55,13 +55,15 @@ 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 (file->ReadObject(&magic) != sizeof(magic)) { |
|
|
|
return FileType::Error; |
|
|
|
} |
|
|
|
|
|
|
|
if (Common::MakeMagic('N', 'S', 'O', '0') == magic) { |
|
|
|
return FileType::NSO; |
|
|
|
if (Common::MakeMagic('N', 'S', 'O', '0') != magic) { |
|
|
|
return FileType::Error; |
|
|
|
} |
|
|
|
|
|
|
|
return FileType::Error; |
|
|
|
return FileType::NSO; |
|
|
|
} |
|
|
|
|
|
|
|
static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data, |
|
|
|
|