fix: Out of bounds read with a zero-size file
This commit is contained in:
parent
7f35d81722
commit
1c8af096de
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user