From 6f6f76f0c07d592ad14b1d64a2e7037deb587c21 Mon Sep 17 00:00:00 2001 From: Dylan Conway Date: Fri, 16 Jan 2026 14:18:48 -0800 Subject: [PATCH] fix(macho): only update signature size on ARM64 with codesigning enabled (#26175) The signature size adjustment was being applied unconditionally, but it should only happen when building for ARM64 and codesigning is enabled. This prevents incorrect offset calculations on non-ARM64 platforms. --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- src/bun.js/webcore/Request.zig | 2 +- src/macho.zig | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/bun.js/webcore/Request.zig b/src/bun.js/webcore/Request.zig index eae240fe9d..75c16cf755 100644 --- a/src/bun.js/webcore/Request.zig +++ b/src/bun.js/webcore/Request.zig @@ -1089,8 +1089,8 @@ const string = []const u8; const Environment = @import("../../env.zig"); const std = @import("std"); -const FetchRedirect = @import("../../http/FetchRedirect.zig").FetchRedirect; const FetchCacheMode = @import("../../http/FetchCacheMode.zig").FetchCacheMode; +const FetchRedirect = @import("../../http/FetchRedirect.zig").FetchRedirect; const FetchRequestMode = @import("../../http/FetchRequestMode.zig").FetchRequestMode; const Method = @import("../../http/Method.zig").Method; diff --git a/src/macho.zig b/src/macho.zig index 50d30abacd..31a2846077 100644 --- a/src/macho.zig +++ b/src/macho.zig @@ -183,8 +183,10 @@ pub const MachoFile = struct { // Only update offsets if the size actually changed if (size_diff != 0) { - // New signature size is the old size plus the size of the hashes for the new pages - sig_size = sig_size + @as(usize, @intCast(size_of_new_hashes)); + if (self.header.cputype == macho.CPU_TYPE_ARM64 and !bun.feature_flag.BUN_NO_CODESIGN_MACHO_BINARY.get()) { + // New signature size is the old size plus the size of the hashes for the new pages + sig_size = sig_size + @as(usize, @intCast(size_of_new_hashes)); + } // We move the offsets of the LINKEDIT segment ahead by `size_diff` linkedit_seg.fileoff += @as(usize, @intCast(size_diff));