| author | |
| committer | |
| log | d0da3d731e40fe9e0b45d50d4c3bf8210b44d472 |
| tree | 3cf117d8843c72440b063570d598d89335f55254 |
| parent | b0c8a3f31631a63bca3a2feece38e57b9a1c5060 |
4 files changed, 11 insertions(+), 11 deletions(-)
lib/std/crypto/Certificate/Bundle/macos.zig+4-4| ... | @@ -20,12 +20,12 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { | ... | @@ -20,12 +20,12 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 20 | var stream = std.io.fixedBufferStream(bytes); | 20 | var stream = std.io.fixedBufferStream(bytes); |
| 21 | const reader = stream.reader(); | 21 | const reader = stream.reader(); |
| 22 | 22 | ||
| 23 | const db_header = try reader.readStructBig(ApplDbHeader); | 23 | const db_header = try reader.readStructEndian(ApplDbHeader, .big); |
| 24 | assert(mem.eql(u8, "kych", &@as([4]u8, @bitCast(db_header.signature)))); | 24 | assert(mem.eql(u8, "kych", &@as([4]u8, @bitCast(db_header.signature)))); |
| 25 | 25 | ||
| 26 | try stream.seekTo(db_header.schema_offset); | 26 | try stream.seekTo(db_header.schema_offset); |
| 27 | 27 | ||
| 28 | const db_schema = try reader.readStructBig(ApplDbSchema); | 28 | const db_schema = try reader.readStructEndian(ApplDbSchema, .big); |
| 29 | 29 | ||
| 30 | var table_list = try gpa.alloc(u32, db_schema.table_count); | 30 | var table_list = try gpa.alloc(u32, db_schema.table_count); |
| 31 | defer gpa.free(table_list); | 31 | defer gpa.free(table_list); |
| ... | @@ -40,7 +40,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { | ... | @@ -40,7 +40,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 40 | for (table_list) |table_offset| { | 40 | for (table_list) |table_offset| { |
| 41 | try stream.seekTo(db_header.schema_offset + table_offset); | 41 | try stream.seekTo(db_header.schema_offset + table_offset); |
| 42 | 42 | ||
| 43 | const table_header = try reader.readStructBig(TableHeader); | 43 | const table_header = try reader.readStructEndian(TableHeader, .big); |
| 44 | 44 | ||
| 45 | if (@as(std.os.darwin.cssm.DB_RECORDTYPE, @enumFromInt(table_header.table_id)) != .X509_CERTIFICATE) { | 45 | if (@as(std.os.darwin.cssm.DB_RECORDTYPE, @enumFromInt(table_header.table_id)) != .X509_CERTIFICATE) { |
| 46 | continue; | 46 | continue; |
| ... | @@ -57,7 +57,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { | ... | @@ -57,7 +57,7 @@ pub fn rescanMac(cb: *Bundle, gpa: Allocator) RescanMacError!void { |
| 57 | for (record_list) |record_offset| { | 57 | for (record_list) |record_offset| { |
| 58 | try stream.seekTo(db_header.schema_offset + table_offset + record_offset); | 58 | try stream.seekTo(db_header.schema_offset + table_offset + record_offset); |
| 59 | 59 | ||
| 60 | const cert_header = try reader.readStructBig(X509CertHeader); | 60 | const cert_header = try reader.readStructEndian(X509CertHeader, .big); |
| 61 | 61 | ||
| 62 | try cb.bytes.ensureUnusedCapacity(gpa, cert_header.cert_size); | 62 | try cb.bytes.ensureUnusedCapacity(gpa, cert_header.cert_size); |
| 63 | 63 |
lib/std/io.zig+2-2| ... | @@ -300,8 +300,8 @@ pub fn GenericReader( | ... | @@ -300,8 +300,8 @@ pub fn GenericReader( |
| 300 | return @errorCast(self.any().readStruct(T)); | 300 | return @errorCast(self.any().readStruct(T)); |
| 301 | } | 301 | } |
| 302 | 302 | ||
| 303 | pub inline fn readStructBig(self: Self, comptime T: type) NoEofError!T { | 303 | pub inline fn readStructEndian(self: Self, comptime T: type, endian: std.builtin.Endian) NoEofError!T { |
| 304 | return @errorCast(self.any().readStructBig(T)); | 304 | return @errorCast(self.any().readStructEndian(T, endian)); |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | pub const ReadEnumError = NoEofError || error{ | 307 | pub const ReadEnumError = NoEofError || error{ |
lib/std/io/Reader.zig+2-2| ... | @@ -332,9 +332,9 @@ pub fn readStruct(self: Self, comptime T: type) anyerror!T { | ... | @@ -332,9 +332,9 @@ pub fn readStruct(self: Self, comptime T: type) anyerror!T { |
| 332 | return res[0]; | 332 | return res[0]; |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | pub fn readStructBig(self: Self, comptime T: type) anyerror!T { | 335 | pub fn readStructEndian(self: Self, comptime T: type, endian: std.builtin.Endian) anyerror!T { |
| 336 | var res = try self.readStruct(T); | 336 | var res = try self.readStruct(T); |
| 337 | if (native_endian != std.builtin.Endian.big) { | 337 | if (native_endian != endian) { |
| 338 | mem.byteSwapAllFields(T, &res); | 338 | mem.byteSwapAllFields(T, &res); |
| 339 | } | 339 | } |
| 340 | return res; | 340 | return res; |
src/link/MachO/fat.zig+3-3| ... | @@ -1,6 +1,6 @@ | ... | @@ -1,6 +1,6 @@ |
| 1 | pub fn isFatLibrary(file: std.fs.File) bool { | 1 | pub fn isFatLibrary(file: std.fs.File) bool { |
| 2 | const reader = file.reader(); | 2 | const reader = file.reader(); |
| 3 | const hdr = reader.readStructBig(macho.fat_header) catch return false; | 3 | const hdr = reader.readStructEndian(macho.fat_header, .big) catch return false; |
| 4 | defer file.seekTo(0) catch {}; | 4 | defer file.seekTo(0) catch {}; |
| 5 | return hdr.magic == macho.FAT_MAGIC; | 5 | return hdr.magic == macho.FAT_MAGIC; |
| 6 | } | 6 | } |
| ... | @@ -13,7 +13,7 @@ pub const Arch = struct { | ... | @@ -13,7 +13,7 @@ pub const Arch = struct { |
| 13 | /// Caller owns the memory. | 13 | /// Caller owns the memory. |
| 14 | pub fn parseArchs(gpa: Allocator, file: std.fs.File) ![]const Arch { | 14 | pub fn parseArchs(gpa: Allocator, file: std.fs.File) ![]const Arch { |
| 15 | const reader = file.reader(); | 15 | const reader = file.reader(); |
| 16 | const fat_header = try reader.readStructBig(macho.fat_header); | 16 | const fat_header = try reader.readStructEndian(macho.fat_header, .big); |
| 17 | assert(fat_header.magic == macho.FAT_MAGIC); | 17 | assert(fat_header.magic == macho.FAT_MAGIC); |
| 18 | 18 | ||
| 19 | var archs = try std.ArrayList(Arch).initCapacity(gpa, fat_header.nfat_arch); | 19 | var archs = try std.ArrayList(Arch).initCapacity(gpa, fat_header.nfat_arch); |
| ... | @@ -21,7 +21,7 @@ pub fn parseArchs(gpa: Allocator, file: std.fs.File) ![]const Arch { | ... | @@ -21,7 +21,7 @@ pub fn parseArchs(gpa: Allocator, file: std.fs.File) ![]const Arch { |
| 21 | 21 | ||
| 22 | var fat_arch_index: u32 = 0; | 22 | var fat_arch_index: u32 = 0; |
| 23 | while (fat_arch_index < fat_header.nfat_arch) : (fat_arch_index += 1) { | 23 | while (fat_arch_index < fat_header.nfat_arch) : (fat_arch_index += 1) { |
| 24 | const fat_arch = try reader.readStructBig(macho.fat_arch); | 24 | const fat_arch = try reader.readStructEndian(macho.fat_arch, .big); |
| 25 | // If we come across an architecture that we do not know how to handle, that's | 25 | // If we come across an architecture that we do not know how to handle, that's |
| 26 | // fine because we can keep looking for one that might match. | 26 | // fine because we can keep looking for one that might match. |
| 27 | const arch: std.Target.Cpu.Arch = switch (fat_arch.cputype) { | 27 | const arch: std.Target.Cpu.Arch = switch (fat_arch.cputype) { |