alexcrichton / xz2-rs

Bindings to liblzma in Rust (xz streams in Rust)
Apache License 2.0
81 stars 52 forks source link

`"corrupt xz stream"` on linux tarball #84

Open aDotInTheVoid opened 3 years ago

aDotInTheVoid commented 3 years ago

xz2 cannot extract the xz file for the linux source code

$ wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.14.1.tar.xz                 
$ sha256sum linux-5.14.1.tar.xz
005bc52a847b7a372a687d536847adb1e1fe0ee571817008632c6e1706d008c7  linux-5.14.1.tar.xz
use std::io::prelude::*;

fn main() {
    let input = std::fs::read("linux-5.14.1.tar.xz").unwrap();
    let mut output = Vec::new();
    xz::read::XzDecoder::new(&*input)
        .read_to_end(&mut output)
        .unwrap();
}
$ cargo run
    Finished dev [unoptimized + debuginfo] target(s) in 0.02s
     Running `/home/nixon/git/nixos/target/debug/why`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Custom { kind: Other, error: "corrupt xz stream" }', why/src/main.rs:8:10
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
$ unxz linux-5.14.1.tar.xz
$ sha256sum linux-5.14.1.tar
f0978dd271f97e6c00c30deffbd1eb0c4d05c3b5e959a67bbfb4bd280817635d  linux-5.14.1.tar
aegoroff commented 2 years ago

try to use XzDecoder::new_multi_decoder(&*input) - it helped me