Closed
Description
Zig Version
0.12.0-dev.985+e44152e25
Steps to Reproduce and Observed Behavior
- You create a tar file using something like
tar -cvf test.tar exec
whereexec
is just a file. - Then using this code here:
const std = @import("std");
pub fn main() !void {
var file = try std.fs.cwd().openFile("test.tar", .{});
defer file.close();
const outdir = try std.fs.cwd().openDir(
"out",
.{},
);
try std.tar.pipeToFileSystem(
outdir,
file.reader(),
.{ .strip_components = 1, .mode_mode = .ignore },
);
}
you attempt to untar it.
Results in:
error: TarComponentsOutsideStrippedPrefix
/usr/zig/lib/std/tar.zig:344:13: 0x2224b5 in stripComponents (test)
return error.TarComponentsOutsideStrippedPrefix;
^
/usr/zig/lib/std/tar.zig:219:35: 0x226260 in pipeToFileSystem__anon_3834 (test)
const file_name = try stripComponents(unstripped_file_name, options.strip_components);
I found this when working on solving #17462
Expected Behavior
It unzips the single file as expected.