Skip to content

Commit ba97b1a

Browse files
mlafeldtandrewrk
authored andcommitted
Merge pull request #23193 from mlafeldt/fix-macho-detection
Fetch: enhance Mach-O executable detection for modern Macs closes #21044
1 parent 72775ad commit ba97b1a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/Package/Fetch.zig

+10-1
Original file line numberDiff line numberDiff line change
@@ -1850,7 +1850,11 @@ const FileHeader = struct {
18501850
return magic_number == std.macho.MH_MAGIC or
18511851
magic_number == std.macho.MH_MAGIC_64 or
18521852
magic_number == std.macho.FAT_MAGIC or
1853-
magic_number == std.macho.FAT_MAGIC_64;
1853+
magic_number == std.macho.FAT_MAGIC_64 or
1854+
magic_number == std.macho.MH_CIGAM or
1855+
magic_number == std.macho.MH_CIGAM_64 or
1856+
magic_number == std.macho.FAT_CIGAM or
1857+
magic_number == std.macho.FAT_CIGAM_64;
18541858
}
18551859

18561860
pub fn isExecutable(self: *FileHeader) bool {
@@ -1875,6 +1879,11 @@ test FileHeader {
18751879
h.bytes_read = 0;
18761880
h.update(&macho64_magic_bytes);
18771881
try std.testing.expect(h.isExecutable());
1882+
1883+
const macho64_cigam_bytes = [_]u8{ 0xFE, 0xED, 0xFA, 0xCF };
1884+
h.bytes_read = 0;
1885+
h.update(&macho64_cigam_bytes);
1886+
try std.testing.expect(h.isExecutable());
18781887
}
18791888

18801889
// Result of the `unpackResource` operation. Enables collecting errors from

0 commit comments

Comments
 (0)