| ... | ... | @@ -93,7 +93,7 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi |
| 93 | 93 | start += 512; |
| 94 | 94 | const file_size = try header.fileSize(); |
| 95 | 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 | 97 | const unstripped_file_name = try header.fullFileName(&file_name_buffer); |
| 98 | 98 | switch (header.fileType()) { |
| 99 | 99 | .directory => { |
| ... | ... | @@ -117,13 +117,15 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi |
| 117 | 117 | start = 0; |
| 118 | 118 | } |
| 119 | 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 | 122 | buffer.len - end, |
| 122 | 123 | rounded_file_size + 512 - file_off -| (end - start), |
| 123 | | ); |
| 124 | )); |
| 124 | 125 | end += try reader.readAtLeast(buffer[end..], ask); |
| 125 | 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 | 129 | try file.writeAll(slice); |
| 128 | 130 | file_off += slice.len; |
| 129 | 131 | start += slice.len; |
| ... | ... | @@ -136,8 +138,8 @@ pub fn pipeToFileSystem(dir: std.fs.Dir, reader: anytype, options: Options) !voi |
| 136 | 138 | } |
| 137 | 139 | }, |
| 138 | 140 | .global_extended_header, .extended_header => { |
| 139 | | start += rounded_file_size; |
| 140 | | if (start > end) return error.TarHeadersTooBig; |
| 141 | if (start + rounded_file_size > end) return error.TarHeadersTooBig; |
| 142 | start = @intCast(usize, start + rounded_file_size); |
| 141 | 143 | }, |
| 142 | 144 | .hard_link => return error.TarUnsupportedFileType, |
| 143 | 145 | .symbolic_link => return error.TarUnsupportedFileType, |