1
0
mirror of synced 2024-11-12 02:00:52 +01:00

fix: Out of bounds read with a zero-size file

This commit is contained in:
WerWolv 2023-11-11 23:11:34 +01:00
parent 7f35d81722
commit 1c8af096de
2 changed files with 4 additions and 2 deletions

View File

@ -64,7 +64,8 @@ namespace hex::plugin::builtin {
}
void FileProvider::readRaw(u64 offset, void *buffer, size_t size) {
if (offset > (this->getActualSize() - size) || buffer == nullptr || size == 0)
auto actualSize = this->getActualSize();
if (actualSize == 0 || (offset + size) > actualSize || buffer == nullptr || size == 0)
return;
std::memcpy(buffer, this->m_file.getMapping() + offset, size);

View File

@ -22,7 +22,8 @@ namespace hex::plugin::builtin {
}
void MemoryFileProvider::readRaw(u64 offset, void *buffer, size_t size) {
if ((offset + size) > this->getActualSize() || buffer == nullptr || size == 0)
auto actualSize = this->getActualSize();
if (actualSize == 0 || (offset + size) > actualSize || buffer == nullptr || size == 0)
return;
std::memcpy(buffer, &this->m_data.front() + offset, size);