diff options
| author | 2018-07-19 16:10:29 -0700 | |
|---|---|---|
| committer | 2018-07-19 16:10:29 -0700 | |
| commit | dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20 (patch) | |
| tree | 9be8e4b3623bc3774bd5be0026e1c171f595e0d6 /src/core/loader/nso.cpp | |
| parent | Merge pull request #717 from lioncash/explicit (diff) | |
| parent | loader/nso: Check if read succeeded in IdentifyFile() before checking magic v... (diff) | |
| download | yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar.gz yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar.xz yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.zip | |
Merge pull request #718 from lioncash/read
loader/nso: Check if read succeeded in IdentifyFile() before checking magic value
Diffstat (limited to 'src/core/loader/nso.cpp')
| -rw-r--r-- | src/core/loader/nso.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/src/core/loader/nso.cpp b/src/core/loader/nso.cpp index f7752e0e3..c66561bf4 100644 --- a/src/core/loader/nso.cpp +++ b/src/core/loader/nso.cpp | |||
| @@ -55,13 +55,15 @@ AppLoader_NSO::AppLoader_NSO(FileSys::VirtualFile file) : AppLoader(std::move(fi | |||
| 55 | 55 | ||
| 56 | FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) { | 56 | FileType AppLoader_NSO::IdentifyType(const FileSys::VirtualFile& file) { |
| 57 | u32 magic = 0; | 57 | u32 magic = 0; |
| 58 | file->ReadObject(&magic); | 58 | if (file->ReadObject(&magic) != sizeof(magic)) { |
| 59 | return FileType::Error; | ||
| 60 | } | ||
| 59 | 61 | ||
| 60 | if (Common::MakeMagic('N', 'S', 'O', '0') == magic) { | 62 | if (Common::MakeMagic('N', 'S', 'O', '0') != magic) { |
| 61 | return FileType::NSO; | 63 | return FileType::Error; |
| 62 | } | 64 | } |
| 63 | 65 | ||
| 64 | return FileType::Error; | 66 | return FileType::NSO; |
| 65 | } | 67 | } |
| 66 | 68 | ||
| 67 | static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data, | 69 | static std::vector<u8> DecompressSegment(const std::vector<u8>& compressed_data, |