Commit 7e751e8040

Mathias Lafeldt <mathias.lafeldt@gmail.com>
2025-03-11 07:12:13
Merge pull request #23193 from mlafeldt/fix-macho-detection
Fetch: enhance Mach-O executable detection for modern Macs closes #21044
1 parent 5ffd8bf
Changed files (1)
src
Package
src/Package/Fetch.zig
@@ -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