Source code

Revision control

Copy as Markdown

Other Tools

diff --git a/src/common/linux/file_id.cc b/src/common/linux/file_id.cc
--- a/src/common/linux/file_id.cc
+++ b/src/common/linux/file_id.cc
@@ -115,28 +115,27 @@ static bool FindElfBuildIDNote(const voi
return false;
}
// Attempt to locate the .text section of an ELF binary and generate
// a simple hash by XORing the first page worth of bytes into |identifier|.
static bool HashElfTextSection(const void* elf_mapped_base,
wasteful_vector<uint8_t>& identifier) {
- identifier.resize(kMDGUIDSize);
-
void* text_section;
size_t text_size;
if (!FindElfSection(elf_mapped_base, ".text", SHT_PROGBITS,
(const void**)&text_section, &text_size) ||
text_size == 0) {
return false;
}
// Only provide |kMDGUIDSize| bytes to keep identifiers produced by this
// function backwards-compatible.
+ identifier.resize(kMDGUIDSize);
my_memset(&identifier[0], 0, kMDGUIDSize);
const uint8_t* ptr = reinterpret_cast<const uint8_t*>(text_section);
const uint8_t* ptr_end = ptr + std::min(text_size, static_cast<size_t>(4096));
while (ptr < ptr_end) {
for (unsigned i = 0; i < kMDGUIDSize; i++)
identifier[i] ^= ptr[i];
ptr += kMDGUIDSize;
}