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.
This commit is contained in:
parent
2ec852dd9f
commit
ed46f3c62a
@ -70,14 +70,18 @@ NAX::NAX(VirtualFile file_, std::array<u8, 0x10> nca_id)
|
|||||||
NAX::~NAX() = default;
|
NAX::~NAX() = default;
|
||||||
|
|
||||||
Loader::ResultStatus NAX::Parse(std::string_view path) {
|
Loader::ResultStatus NAX::Parse(std::string_view path) {
|
||||||
if (file->ReadObject(header.get()) != sizeof(NAXHeader))
|
if (file == nullptr) {
|
||||||
|
return Loader::ResultStatus::ErrorNullFile;
|
||||||
|
}
|
||||||
|
if (file->ReadObject(header.get()) != sizeof(NAXHeader)) {
|
||||||
return Loader::ResultStatus::ErrorBadNAXHeader;
|
return Loader::ResultStatus::ErrorBadNAXHeader;
|
||||||
|
}
|
||||||
if (header->magic != Common::MakeMagic('N', 'A', 'X', '0'))
|
if (header->magic != Common::MakeMagic('N', 'A', 'X', '0')) {
|
||||||
return Loader::ResultStatus::ErrorBadNAXHeader;
|
return Loader::ResultStatus::ErrorBadNAXHeader;
|
||||||
|
}
|
||||||
if (file->GetSize() < NAX_HEADER_PADDING_SIZE + header->file_size)
|
if (file->GetSize() < NAX_HEADER_PADDING_SIZE + header->file_size) {
|
||||||
return Loader::ResultStatus::ErrorIncorrectNAXFileSize;
|
return Loader::ResultStatus::ErrorIncorrectNAXFileSize;
|
||||||
|
}
|
||||||
|
|
||||||
keys.DeriveSDSeedLazy();
|
keys.DeriveSDSeedLazy();
|
||||||
std::array<Core::Crypto::Key256, 2> sd_keys{};
|
std::array<Core::Crypto::Key256, 2> sd_keys{};
|
||||||
|
Loading…
Reference in New Issue
Block a user