From c50d52d0a6fa9ded761fcc0819617f5ed473fab6 Mon Sep 17 00:00:00 2001 From: WerWolv Date: Sun, 14 May 2023 22:46:19 +0200 Subject: [PATCH] fix: Crash when reading from modified bytes --- .../source/content/providers/file_provider.cpp | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/plugins/builtin/source/content/providers/file_provider.cpp b/plugins/builtin/source/content/providers/file_provider.cpp index ef37e61e7..384386382 100644 --- a/plugins/builtin/source/content/providers/file_provider.cpp +++ b/plugins/builtin/source/content/providers/file_provider.cpp @@ -40,7 +40,7 @@ namespace hex::plugin::builtin { if (overlays) [[likely]] { for (const auto&[patchOffset, patchData] : getPatches()) { - if (patchOffset >= offset && patchOffset <= (offset + size)) + if (patchOffset >= offset && patchOffset < (offset + size)) reinterpret_cast(buffer)[patchOffset - offset] = patchData; } @@ -59,13 +59,6 @@ namespace hex::plugin::builtin { if (offset > (this->getActualSize() - size) || buffer == nullptr || size == 0) return; - /*auto currSize = std::fs::file_size(this->m_path); - if (this->m_fileSize != currSize) [[unlikely]] { - this->m_fileSize = currSize; - this->m_file.unmap(); - this->m_file.map(); - }*/ - std::memcpy(buffer, this->m_file.getMapping() + offset, size); } @@ -73,13 +66,6 @@ namespace hex::plugin::builtin { if ((offset + size) > this->getActualSize() || buffer == nullptr || size == 0) return; - auto currSize = std::fs::file_size(this->m_path); - if (this->m_fileSize != currSize) [[unlikely]] { - this->m_fileSize = currSize; - this->m_file.unmap(); - this->m_file.map(); - } - std::memcpy(this->m_file.getMapping() + offset, buffer, size); }