NewsCrawler.org

The hardest tarball: one archive, eight different extraction results

The author describes an archive that a single GNU tar command can create, but that different tar tools extract in different ways. The command builds three entries: file, a hard link[1] to it renamed café, and an empty file named empty. A pax header[2] sets the hard link's size to 512 bytes, which is exactly the size of a tar header.

POSIX[3] says data blocks for a hard link may be included in pax archives, but the author finds the implications unclear. GNU tar, BusyBox, Python, Go and Perl extract the three files as expected, while bsdtar writes the 512 bytes into the hard link, so file ends up containing the tar header of empty. 7-Zip, node-tar, tar-fs and Rust's tar libraries skip those bytes and leave only file and café.

Other tools produce still stranger results. Java's Commons Compress creates a separate file holding the header of empty, PHP's PharData makes café an empty file, and R extracts empty filled with 512 bytes from an end-of-archive marker[4]. The .NET, Julia and uv's tar-codec implementations reject the archive. The author collects 134 such tricky tarballs in the test suite tar-minefield.

Read the original stoppels.chDiscussion

Sources

Published: First seen: Читать по-русски

Open as a page