Skip to content

Bug: Extracting tar failed due to GNU Sparse File extension not properly supported #295

Description

@NobodyXu

When extracting cbindgen-0.24.3-x86_64-apple-darwin.tar.gz using the following equivalent code:

use flate2::read::GzDecoder;
use tar::Archive;

let tar = GzDecoder::new(dat);
Archive::new(tar).unpack(path)?;

where dat is some readable that is pipelined from the downloading stage, I got:

/var/folders/4h/3pck4_r16tn6960znvv4w0nw0000gn/T/.tmp7GLCIo/bin-cbindgen
└── GNUSparseFile.0
    └── cbindgen

1 directory, 1 file

Using file cbindgen shows that it is just data, does not have executable set and cannot be executed after chmod +x cbindgen.

While it should be:

/var/folders/4h/3pck4_r16tn6960znvv4w0nw0000gn/T/.tmp7GLCIo/bin-cbindgen
└── cbindgen

I used bsdtar 3.5.1 - libarchive 3.5.1 zlib/1.2.11 liblzma/5.0.5 bz2lib/1.0.8 and it handles it just fine.

Here's the relevant part of the Cargo.toml:

flate2 = { version = "1.0.24", features = ["zlib-ng"], default-features = false }
tar = "0.4.38"

I discovered this bug in cargo-bins/cargo-binstall#174

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions