From c86233cc802962765b0a510393c9c4c60aba4a42 Mon Sep 17 00:00:00 2001 From: "chss95cs@gmail.com" Date: Sun, 23 Apr 2023 12:52:03 -0400 Subject: [PATCH] Detect corrupted xiso images that have file entries that are out of range and show a fatal error. --- src/xenia/vfs/devices/disc_image_file.cc | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/xenia/vfs/devices/disc_image_file.cc b/src/xenia/vfs/devices/disc_image_file.cc index 821189630..dab4f9e08 100644 --- a/src/xenia/vfs/devices/disc_image_file.cc +++ b/src/xenia/vfs/devices/disc_image_file.cc @@ -11,8 +11,8 @@ #include +#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);