diff options
| author | fn ⌃ ⌥ <70830482+FnControlOption@users.noreply.github.com> | 2023-01-16 14:34:04 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-01-16 22:34:04 +0000 |
| commit | e45b471ad35828c5a435b6df7b672f83e8e69b6a (patch) | |
| tree | 3c3fdeae57c337db7b2b39fafb01bc2dce1568f4 /src | |
| parent | b42bd759a7bdb6bc1d84c640d68e5384dc35776d (diff) | |
| download | zig-e45b471ad35828c5a435b6df7b672f83e8e69b6a.tar.gz zig-e45b471ad35828c5a435b6df7b672f83e8e69b6a.zip | |
Find system-installed root SSL certificates on macOS (#14325)
Diffstat (limited to 'src')
| -rw-r--r-- | src/link/MachO/fat.zig | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/link/MachO/fat.zig b/src/link/MachO/fat.zig index 7c328c1418..81b0685418 100644 --- a/src/link/MachO/fat.zig +++ b/src/link/MachO/fat.zig @@ -1,9 +1,7 @@ const std = @import("std"); -const builtin = @import("builtin"); const log = std.log.scoped(.archive); const macho = std.macho; const mem = std.mem; -const native_endian = builtin.target.cpu.arch.endian(); pub fn decodeArch(cputype: macho.cpu_type_t, comptime logError: bool) !std.Target.Cpu.Arch { const cpu_arch: std.Target.Cpu.Arch = switch (cputype) { @@ -19,23 +17,13 @@ pub fn decodeArch(cputype: macho.cpu_type_t, comptime logError: bool) !std.Targe return cpu_arch; } -fn readFatStruct(reader: anytype, comptime T: type) !T { - // Fat structures (fat_header & fat_arch) are always written and read to/from - // disk in big endian order. - var res = try reader.readStruct(T); - if (native_endian != std.builtin.Endian.Big) { - mem.byteSwapAllFields(T, &res); - } - return res; -} - pub fn getLibraryOffset(reader: anytype, cpu_arch: std.Target.Cpu.Arch) !u64 { - const fat_header = try readFatStruct(reader, macho.fat_header); + const fat_header = try reader.readStructBig(macho.fat_header); if (fat_header.magic != macho.FAT_MAGIC) return 0; var fat_arch_index: u32 = 0; while (fat_arch_index < fat_header.nfat_arch) : (fat_arch_index += 1) { - const fat_arch = try readFatStruct(reader, macho.fat_arch); + const fat_arch = try reader.readStructBig(macho.fat_arch); // If we come across an architecture that we do not know how to handle, that's // fine because we can keep looking for one that might match. const lib_arch = decodeArch(fat_arch.cputype, false) catch |err| switch (err) { |
