Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing Mach-O magic bytes #136

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .changes/macho-magic-numbers.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"cargo-packager": patch
"@crabnebula/packager": patch
---

MacOS code signing did not respect MACH-O header magic bytes 0xBEBAFECA and 0xFEEDFACE
11 changes: 9 additions & 2 deletions crates/packager/src/package/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,15 @@ pub(crate) fn package(ctx: &Context) -> crate::Result<Vec<PathBuf>> {
let mut buffer = [0; 4];
std::io::Read::read_exact(&mut open_file, &mut buffer)?;

const MACH_O_MAGIC_NUMBERS: [u32; 5] =
[0xfeedface, 0xfeedfacf, 0xcafebabe, 0xcefaedfe, 0xcffaedfe];
const MACH_O_MAGIC_NUMBERS: [u32; 5] = [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace this with [u32; 7]

0xfeedface, // 32 bit binary little-endian
0xcefaedfe, // 32 bit binary big-endian
0xfeedfacf, // 64 bit binary little-endian
0xcffaedfe, // 64 bit binary big-endian
0xcafebabe, // universal binary
0xfeedfeed, // core dump files
0xfacffeed, // used by electron on x86
];

let magic = u32::from_be_bytes(buffer);

Expand Down
Loading