1
0
mirror of synced 2024-09-23 19:18:24 +02:00

fix: Segfault when hashing regions spanning multiple MiBs (#1804)

### Problem description

Attempting to do an MD5 hash of a large region (e.g. 2 MiB, ``u8
data[0x200000]``) crashes with a segfault.

### Implementation description

In ``hex::plugin::hashes::hashProviderRegionWithHashLib()``,
``hashFunction->TransformBytes()`` is called with an offset of 0,
because it iterates over ``data`` and not the entire region.
This commit is contained in:
Jean-François Nguyen 2024-07-21 20:35:38 +02:00 committed by GitHub
parent 75e5dbaaa4
commit e50b6733c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -27,7 +27,7 @@ namespace hex::plugin::hashes {
u64 readSize = std::min<u64>(1_MiB, (region.getEndAddress() - address) + 1);
auto data = reader.read(address, readSize);
hashFunction->TransformBytes({ data.begin(), data.end() }, address - region.getStartAddress(), data.size());
hashFunction->TransformBytes({ data.begin(), data.end() }, 0, data.size());
}
auto result = hashFunction->TransformFinal();