Skip to content

std.tar: handle tar files with symbolic links #16678

Closed
@mitchellh

Description

@mitchellh

Zig Version

0.11.0-dev.4404+4f6013bf5

Steps to Reproduce and Observed Behavior

Use any data.tar.gz below that contains a symbolic link.

You'll get a TarUnsupportedFileType which is explicitly returned from std.tar if it seems a symlink.

const std = @import("std");

/// USE BAD TAR.GZ HERE
const data = @embedFile("data.tar.gz");

pub fn main() !void {
    var gpa = std.heap.GeneralPurposeAllocator(.{}){};
    defer _ = gpa.deinit();
    const alloc = gpa.allocator();

    var out_dir = try std.fs.cwd().openDir("test-out", .{});

    var stream = std.io.fixedBufferStream(data);
    var decompress = try std.compress.gzip.decompress(alloc, stream.reader());
    defer decompress.deinit();

    try std.tar.pipeToFileSystem(out_dir, decompress.reader(), .{
        .strip_components = 1,
        .mode_mode = .ignore,
    });
}

Expected Behavior

This should work. A lot of source archives for the Zig package manager contain symbolic links. Major source archives that I use that have symbolic links:

  • libxml2
  • harfbuzz

This will also impair #16643 (not block) because downloading source archives for me will be a big use case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugObserved behavior contradicts documented or intended behaviorstandard 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