Merge pull request #23193 from mlafeldt/fix-macho-detection

Fetch: enhance Mach-O executable detection for modern Macs

closes #21044
This commit is contained in:
Mathias Lafeldt 2025-03-11 07:12:13 +01:00 committed by GitHub
parent 5ffd8bf5f6
commit 7e751e8040
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -1850,7 +1850,11 @@ const FileHeader = struct {
return magic_number == std.macho.MH_MAGIC or
magic_number == std.macho.MH_MAGIC_64 or
magic_number == std.macho.FAT_MAGIC or
magic_number == std.macho.FAT_MAGIC_64;
magic_number == std.macho.FAT_MAGIC_64 or
magic_number == std.macho.MH_CIGAM or
magic_number == std.macho.MH_CIGAM_64 or
magic_number == std.macho.FAT_CIGAM or
magic_number == std.macho.FAT_CIGAM_64;
}
pub fn isExecutable(self: *FileHeader) bool {
@ -1875,6 +1879,11 @@ test FileHeader {
h.bytes_read = 0;
h.update(&macho64_magic_bytes);
try std.testing.expect(h.isExecutable());
const macho64_cigam_bytes = [_]u8{ 0xFE, 0xED, 0xFA, 0xCF };
h.bytes_read = 0;
h.update(&macho64_cigam_bytes);
try std.testing.expect(h.isExecutable());
}
// Result of the `unpackResource` operation. Enables collecting errors from