authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-10 23:19:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-01-11 15:39:49-08:00
log476cbe871aedf13a48be040dd04aa2fc5e59332a
tree2826230fdb6823d727eebdf47f09214eab26fa4d
parentfe8951cc941a55b23387b8d8bc09c62ea71409dd

fix build failures on 32-bit arm due to u64/usize coercion


2 files changed, 33 insertions(+), 7 deletions(-)

lib/std/http/Client.zig+25-1
...@@ -625,6 +625,29 @@ pub const Request = struct {...@@ -625,6 +625,29 @@ pub const Request = struct {
625 InvalidSignature,625 InvalidSignature,
626 NotSquare,626 NotSquare,
627 DiskQuota,627 DiskQuota,
628 InvalidEnd,
629 Incomplete,
630 InvalidIpv4Mapping,
631 InvalidIPAddressFormat,
632 BadPathName,
633 DeviceBusy,
634 FileBusy,
635 FileLocksNotSupported,
636 InvalidHandle,
637 InvalidUtf8,
638 NameTooLong,
639 NoDevice,
640 PathAlreadyExists,
641 PipeBusy,
642 SharingViolation,
643 SymLinkLoop,
644 FileSystem,
645 InterfaceNotFound,
646 AlreadyBound,
647 FileDescriptorNotASocket,
648 NetworkSubsystemFailed,
649 NotDir,
650 ReadOnlyFileSystem,
628 };651 };
629652
630 pub fn read(req: *Request, buffer: []u8) ReadError!usize {653 pub fn read(req: *Request, buffer: []u8) ReadError!usize {
...@@ -770,7 +793,8 @@ pub const Request = struct {...@@ -770,7 +793,8 @@ pub const Request = struct {
770 }793 }
771 },794 },
772 .chunk_data => {795 .chunk_data => {
773 const sub_amt = @min(req.response.next_chunk_length, in.len);796 // TODO https://github.com/ziglang/zig/issues/14039
797 const sub_amt = @intCast(usize, @min(req.response.next_chunk_length, in.len));
774 req.response.next_chunk_length -= sub_amt;798 req.response.next_chunk_length -= sub_amt;
775 if (req.response.next_chunk_length > 0) {799 if (req.response.next_chunk_length > 0) {
776 if (in.ptr == buffer.ptr) {800 if (in.ptr == buffer.ptr) {
lib/std/tar.zig+8-6
...@@ -93,7 +93,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi...@@ -93,7 +93,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
93 start += 512;93 start += 512;
94 const file_size = try header.fileSize();94 const file_size = try header.fileSize();
95 const rounded_file_size = std.mem.alignForwardGeneric(u64, file_size, 512);95 const rounded_file_size = std.mem.alignForwardGeneric(u64, file_size, 512);
96 const pad_len = rounded_file_size - file_size;96 const pad_len = @intCast(usize, rounded_file_size - file_size);
97 const unstripped_file_name = try header.fullFileName(&file_name_buffer);97 const unstripped_file_name = try header.fullFileName(&file_name_buffer);
98 switch (header.fileType()) {98 switch (header.fileType()) {
99 .directory => {99 .directory => {
...@@ -117,13 +117,15 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi...@@ -117,13 +117,15 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
117 start = 0;117 start = 0;
118 }118 }
119 // Ask for the rounded up file size + 512 for the next header.119 // Ask for the rounded up file size + 512 for the next header.
120 const ask = @min(120 // TODO: https://github.com/ziglang/zig/issues/14039
121 const ask = @intCast(usize, @min(
121 buffer.len - end,122 buffer.len - end,
122 rounded_file_size + 512 - file_off -| (end - start),123 rounded_file_size + 512 - file_off -| (end - start),
123 );124 ));
124 end += try reader.readAtLeast(buffer[end..], ask);125 end += try reader.readAtLeast(buffer[end..], ask);
125 if (end - start < ask) return error.UnexpectedEndOfStream;126 if (end - start < ask) return error.UnexpectedEndOfStream;
126 const slice = buffer[start..@min(file_size - file_off + start, end)];127 // TODO: https://github.com/ziglang/zig/issues/14039
128 const slice = buffer[start..@intCast(usize, @min(file_size - file_off + start, end))];
127 try file.writeAll(slice);129 try file.writeAll(slice);
128 file_off += slice.len;130 file_off += slice.len;
129 start += slice.len;131 start += slice.len;
...@@ -136,8 +138,8 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi...@@ -136,8 +138,8 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi
136 }138 }
137 },139 },
138 .global_extended_header, .extended_header => {140 .global_extended_header, .extended_header => {
139 start += rounded_file_size;141 if (start + rounded_file_size > end) return error.TarHeadersTooBig;
140 if (start > end) return error.TarHeadersTooBig;142 start = @intCast(usize, start + rounded_file_size);
141 },143 },
142 .hard_link => return error.TarUnsupportedFileType,144 .hard_link => return error.TarUnsupportedFileType,
143 .symbolic_link => return error.TarUnsupportedFileType,145 .symbolic_link => return error.TarUnsupportedFileType,