diff options
| author | 2020-07-20 10:30:25 -0400 | |
|---|---|---|
| committer | 2020-07-29 06:50:30 -0400 | |
| commit | ed46f3c62a7649cfaada61c8cdb9dfd91e54a9db (patch) | |
| tree | d93cd38ef3d74cd5870a602b63ebec6c5baed85b | |
| parent | registered_cache: Add support for removing folder ncas (diff) | |
| download | yuzu-ed46f3c62a7649cfaada61c8cdb9dfd91e54a9db.tar.gz yuzu-ed46f3c62a7649cfaada61c8cdb9dfd91e54a9db.tar.xz yuzu-ed46f3c62a7649cfaada61c8cdb9dfd91e54a9db.zip | |
xts_archive: Check if the file is nullptr prior to parsing
Fixes an access violation where the file no longer exists at the specified path while being parsed.
| -rw-r--r-- | src/core/file_sys/xts_archive.cpp | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/core/file_sys/xts_archive.cpp b/src/core/file_sys/xts_archive.cpp index 86e06ccb9..81413c684 100644 --- a/src/core/file_sys/xts_archive.cpp +++ b/src/core/file_sys/xts_archive.cpp | |||
| @@ -70,14 +70,18 @@ NAX::NAX(VirtualFile file_, std::array<u8, 0x10> nca_id) | |||
| 70 | NAX::~NAX() = default; | 70 | NAX::~NAX() = default; |
| 71 | 71 | ||
| 72 | Loader::ResultStatus NAX::Parse(std::string_view path) { | 72 | Loader::ResultStatus NAX::Parse(std::string_view path) { |
| 73 | if (file->ReadObject(header.get()) != sizeof(NAXHeader)) | 73 | if (file == nullptr) { |
| 74 | return Loader::ResultStatus::ErrorNullFile; | ||
| 75 | } | ||
| 76 | if (file->ReadObject(header.get()) != sizeof(NAXHeader)) { | ||
| 74 | return Loader::ResultStatus::ErrorBadNAXHeader; | 77 | return Loader::ResultStatus::ErrorBadNAXHeader; |
| 75 | 78 | } | |
| 76 | if (header->magic != Common::MakeMagic('N', 'A', 'X', '0')) | 79 | if (header->magic != Common::MakeMagic('N', 'A', 'X', '0')) { |
| 77 | return Loader::ResultStatus::ErrorBadNAXHeader; | 80 | return Loader::ResultStatus::ErrorBadNAXHeader; |
| 78 | 81 | } | |
| 79 | if (file->GetSize() < NAX_HEADER_PADDING_SIZE + header->file_size) | 82 | if (file->GetSize() < NAX_HEADER_PADDING_SIZE + header->file_size) { |
| 80 | return Loader::ResultStatus::ErrorIncorrectNAXFileSize; | 83 | return Loader::ResultStatus::ErrorIncorrectNAXFileSize; |
| 84 | } | ||
| 81 | 85 | ||
| 82 | keys.DeriveSDSeedLazy(); | 86 | keys.DeriveSDSeedLazy(); |
| 83 | std::array<Core::Crypto::Key256, 2> sd_keys{}; | 87 | std::array<Core::Crypto::Key256, 2> sd_keys{}; |