1changeset:   571402:0c63dcd7a1c6
2user:        Steven Michaud <smichaud@pobox.com>
3date:        Tue Nov 19 21:42:37 2019 +0000
4summary:     Bug 1371390 - Pay attention to macho images' cpusubtype when creating minidumps (revised). r=gsvelto
5
6diff --git a/src/common/mac/macho_walker.cc b/src/common/mac/macho_walker.cc
7--- a/src/common/mac/macho_walker.cc
8+++ b/src/common/mac/macho_walker.cc
9@@ -151,16 +151,18 @@ bool MachoWalker::FindHeader(cpu_type_t
10     // header
11     struct mach_header header;
12     if (!ReadBytes(&header, sizeof(header), 0))
13       return false;
14
15     if (magic == MH_CIGAM || magic == MH_CIGAM_64)
16       breakpad_swap_mach_header(&header);
17
18+    header.cpusubtype &= ~CPU_SUBTYPE_MASK;
19+
20     if (cpu_type != header.cputype ||
21         (cpu_subtype != CPU_SUBTYPE_MULTIPLE &&
22          cpu_subtype != header.cpusubtype)) {
23       return false;
24     }
25
26     offset = 0;
27     return true;
28@@ -180,16 +182,18 @@ bool MachoWalker::FindHeader(cpu_type_t
29     struct fat_arch arch;
30     for (uint32_t i = 0; i < fat.nfat_arch; ++i) {
31       if (!ReadBytes(&arch, sizeof(arch), offset))
32         return false;
33
34       if (NXHostByteOrder() != NX_BigEndian)
35         breakpad_swap_fat_arch(&arch, 1);
36
37+      arch.cpusubtype &= ~CPU_SUBTYPE_MASK;
38+
39       if (arch.cputype == cpu_type &&
40           (cpu_subtype == CPU_SUBTYPE_MULTIPLE ||
41            arch.cpusubtype == cpu_subtype)) {
42         offset = arch.offset;
43         return true;
44       }
45
46       offset += sizeof(arch);
47
48