Bug 1861751 Part 4: Add tests of invalid buffers in various usages. r=webgpu-reviewer...
[gecko.git] / toolkit / crashreporter / breakpad-patches / 10-macho-cpu-subtype.patch
blobbe743f9fe7a1aed77339e5399d278cdc233d8454
1 changeset: 571402:0c63dcd7a1c6
2 user: Steven Michaud <smichaud@pobox.com>
3 date: Tue Nov 19 21:42:37 2019 +0000
4 summary: Bug 1371390 - Pay attention to macho images' cpusubtype when creating minidumps (revised). r=gsvelto
6 diff --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;
15 if (magic == MH_CIGAM || magic == MH_CIGAM_64)
16 breakpad_swap_mach_header(&header);
18 + header.cpusubtype &= ~CPU_SUBTYPE_MASK;
20 if (cpu_type != header.cputype ||
21 (cpu_subtype != CPU_SUBTYPE_MULTIPLE &&
22 cpu_subtype != header.cpusubtype)) {
23 return false;
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;
34 if (NXHostByteOrder() != NX_BigEndian)
35 breakpad_swap_fat_arch(&arch, 1);
37 + arch.cpusubtype &= ~CPU_SUBTYPE_MASK;
39 if (arch.cputype == cpu_type &&
40 (cpu_subtype == CPU_SUBTYPE_MULTIPLE ||
41 arch.cpusubtype == cpu_subtype)) {
42 offset = arch.offset;
43 return true;
46 offset += sizeof(arch);