The Hardest Tarball?
stoppels.ch
stoppels.ch
How so? If the data blocks are included, then those are the intended content of the file behind that hard link. They should overwrite the previous content of the file.
> So the 512 bytes after the hard link are its data, and not the header of empty as we archived it?
Yes, precisely.
> How can a hard link have different contents from its previous counterpart file?
Why, very simply: while the archive was being created, the file behind the two different hard links changed; the archival utility noticed it, and included the new content of the file as the content for the second hard link instead of rewinding and overwriting the original file in the archive (which would be impossible to do on a tape, you know). At least I believe that's what was the rationale for this allowance, and the intended behavior on the extraction.
(I maintain several of the tar parsers mentioned in this post, which I appreciate for its clear treatment of a larger differential problem in the tar ecosystem.)
Although now comes the hard part: filing defect reports and convincing other people.
No, I wasn't even born back then :) But I too had to look into implementing basic tar support at some point of my career and golly gee willikers, what a trip it was. It seems that, for whatever reason, people just can not invent a simple, straightforward (but capable!) archive format.
At the bottom, there's a link to much more edge cases.
It reminds me of this beauty: "Parsing JSON is a Minefield" https://news.ycombinator.com/item?id=16897061
While this is the safest choice, it is the least helpful, I would always prefer to get something out of an archive then nothing. Damage/irregularity to an archive shouldn't prevent data inspection, just a warning and a way to fall back with caveats for what can be extracted.
Now if I'm a user trying to extract the file then I'd want to get as much as possible.
The POSIX standard promotes best-effort extraction, which is reasonable for backups, but a liability for distribution.
Julia's Tar.jl was developed for Pkg.jl and tar-codec for uv, so these are focused on the security aspect of software distribution.
I would argue the correct answer can have both.
Fail by default, fail with a clear error that says the file is damaged, then offer an explicitly opt-in path to try your best anyways, preferably one where the command line option is something like --dangerous-try-extract-anyways and will itself fail on non-broken files so it can't just be shoved in a script as a way to "make sure it works".
* https://mbsd.evolvis.org/pax.htm
* https://manpages.debian.org/trixie/pax/index.html
No, it's not libarchive's bsdtar. There's more than 1 tar in the BSD world.
But the ambiguity of this tar files… I guess the “correct” extraction for what I’m doing would require figuring out what the system that is processing the tar files used and copy that behavior, which is non-trivial if you don’t know what an embedded device is using behind the scenes.
For your use case it would make sense to pick the strictest tar parser, such that you can error or warn on most ambiguities. In practice these ambiguities are rare.
(Another way of saying that is that we live in a post-Postel world[1].)
[1]: https://alexgaynor.net/2025/mar/25/postels-law-and-the-three...
Surely "tarpit" is a more natural name?
I feel like the most faithful extraction would dictate that any field in the original header should take precedence over the PaxHeader's iff the PaxHeader field's value would've been representable in the original field. Anyone have thoughts?
pax does not prescribe what to do in these kinds of invalid states, so there’s a long tail of people making educated guesses.
(On a more basic level, I can imagine it would be even more differential prone for the precedence rule to be “pax, but not always.” pax still makes it complicated but that would be another whole circle of hell.)
I’m damn convinced cpio never took off because the CLI tool’s syntax is a horrible abomination… Picking “-i” to EXTRACT is wild. Not being able to archive a directory tree without 3rd party assistance seems a bit much, even for the UNIX philosophy…
Hit up Wikipedia for tarball format and you may agree with me. It's a classic example of a standard where you look at it and go, "??? Who asked for that?". I'm not surprised the article focuses on pax when finding tar inconsistencies. Original tar is just fine.
(Users also want things like filenames that are longer than 100 characters, for obvious reasons.)