Unpacking tar archive with long link in it results in truncated filenames
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 739
- Forks
- 245
- PR merge metrics
- No merged PRs in 30d
Description
Context
I'm using tar to extract the contents downloaded from https://repo1.maven.org/maven2/org/jruby/jruby-dist/9.4.8.0/jruby-dist-9.4.8.0-bin.tar.gz for re-packaging it and uploading it to S3 https://github.com/heroku/docker-heroku-ruby-builder/blob/9e64b4401be4df7c158c9253290f6a3248927023/shared/src/lib.rs#L24-L31.
Unfortunately I've learned that this file uses ././@LongLink and it seems that the rust tar archive truncates the file by default. To demonstrate the issue I made a reproduction https://github.com/schneems/tar_long_link_repro.
Reproduction
$ git clone https://github.com/schneems/tar_long_link_repro
$ cd tar_long_link_repro
Then run it:
$ cargo run
Expected
I expect that tmp/rust-extracted/jruby-9.4.8.0/lib/ruby/stdlib/bundler/vendor/molinillo/lib/molinillo/delegates will contain a file specification_provider.rb.
Actual
It does not, the command fails an assertion:
$ cargo run
Finished `dev` profile [unoptimized + debuginfo] target(s) in 0.01s
Running `target/debug/tar_long_link_repro`
thread 'main' panicked at src/main.rs:32:5:
expected ["resolution_state.rb", "specification_provide"] to include "specification_provider.rb" but it did not
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
Note the filename seems truncated:
$ ls tmp/rust-extracted/jruby-9.4.8.0/lib/ruby/stdlib/bundler/vendor/molinillo/lib/molinillo/delegates
resolution_state.rb specification_provide
More
I see there that the header and entry inside of tar are aware of the concept of long names (https://docs.rs/tar/0.4.41/tar/struct.Header.html?search=long), but I'm not sure how to unpack a Gnu tar file that has them. If the feature exists, we could possibly update the documentation to make it clearer.
- Update: Confirming the file contains long links, debugging via ruby: https://gist.github.com/schneems/f0ce0d4eea9392dbac635939a9f64e5d
- Update: Python's tarfile module seems to do the right thing here https://gist.github.com/schneems/c6399a6e53457447d0efbbd690a1a6a9
- Update I found a github repo that contains a gnu fixture for a small gnu tar file with a long link, however
tar-rsseems to not show the same issue with it https://github.com/projg2/tar-test-inputs/tree/a2110a6ffec66690123335f34a84626d62a7b541/long-paths
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the linked tar_long_link_repro with cargo run and inspect src/main.rs:32 to confirm the truncated filename. Read the tar Header long-name documentation and compare the GNU long-link fixture mentioned in the issue. Done means GNU tar archives extract the complete specification_provider.rb filename without breaking existing archive handling.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100