From e50b6733c46a024ffe5bb00da452cad4996d0d06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Fran=C3=A7ois=20Nguyen?= Date: Sun, 21 Jul 2024 20:35:38 +0200 Subject: [PATCH] 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. --- plugins/hashes/source/content/hashes.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/hashes/source/content/hashes.cpp b/plugins/hashes/source/content/hashes.cpp index e3b0b3131..19b041b4b 100644 --- a/plugins/hashes/source/content/hashes.cpp +++ b/plugins/hashes/source/content/hashes.cpp @@ -27,7 +27,7 @@ namespace hex::plugin::hashes { u64 readSize = std::min(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();