gecko-dev/toolkit/crashreporter/breakpad-patches/28-no-garbage-in-code-ids.patch
Gabriele Svelto 3487586966 Bug 1756771 - Pack all Breakpad CPU context structures consistently r=glandium
Also add out-of-tree patches for bugs we fixed in the meantime.

Differential Revision: https://phabricator.services.mozilla.com/D139466
2022-03-03 13:14:55 +00:00

34 lines
1.2 KiB
Diff

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;
}