Skip to content

std.tar single file tars fail. #17620

Closed
@Rexicon226

Description

@Rexicon226

Zig Version

0.12.0-dev.985+e44152e25

Steps to Reproduce and Observed Behavior

  1. You create a tar file using something like tar -cvf test.tar exec where exec is just a file.
  2. 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorcontributor friendlyThis issue is limited in scope and/or knowledge of Zig internals.standard libraryThis issue involves writing Zig code for the standard library.

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions