Merge pull request #157 from chrisps/canary_experimental

[VFS] Show fatal error message for disc images with out of bounds entries
This commit is contained in:
chrisps 2023-04-23 13:19:13 -04:00 committed by GitHub
commit 9992d20079
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 7 additions and 1 deletions

View File

@ -11,8 +11,8 @@
#include <algorithm>
#include "xenia/base/logging.h"
#include "xenia/vfs/devices/disc_image_entry.h"
namespace xe {
namespace vfs {
@ -28,6 +28,12 @@ X_STATUS DiscImageFile::ReadSync(void* buffer, size_t buffer_length,
if (byte_offset >= entry_->size()) {
return X_STATUS_END_OF_FILE;
}
if (entry_->data_offset() >= entry_->mmap()->size()) {
xe::FatalError("This ISO image is corrupted and cannot be played.");
return X_STATUS_END_OF_FILE;
}
size_t real_offset = entry_->data_offset() + byte_offset;
size_t real_length =
std::min(buffer_length, entry_->data_size() - byte_offset);