summaryrefslogtreecommitdiffstats
path: root/src/core/loader
diff options
context:
space:
mode:
authorbunnei <bunneidev@gmail.com>2018-07-20 01:10:29 +0200
committerGitHub <noreply@github.com>2018-07-20 01:10:29 +0200
commitdd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20 (patch)
tree9be8e4b3623bc3774bd5be0026e1c171f595e0d6 /src/core/loader
parentMerge pull request #717 from lioncash/explicit (diff)
parentloader/nso: Check if read succeeded in IdentifyFile() before checking magic value (diff)
downloadyuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar
yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar.gz
yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar.bz2
yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar.lz
yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar.xz
yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.tar.zst
yuzu-dd0446ff437a0d65a447b9f52eaf0fb2fd8d5b20.zip
Diffstat (limited to 'src/core/loader')
-rw-r--r--src/core/loader/nso.cpp10
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
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,