summaryrefslogtreecommitdiffstats
path: root/toolkit/crashreporter/breakpad-patches/28-no-garbage-in-code-ids.patch
blob: 64f791d01e69bff99f9b7451567dd41782247bf4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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;
   }