开发者 Haampie Stoppels 于 2026 年 11 月 7 日发布了一个名为 hardest.tar 的精心构造的 GNU tar 归档文件,该文件利用 pax 格式、UTF-8 文件名及硬链接大小覆盖特性,导致不同解压工具在解析时产生八种截然不同的结果 1。这一案例源自 Stoppels 开发的测试套件 haampie/tar-minefield,旨在揭示 tar 格式在跨平台实现中的兼容性问题及规范模糊地带,是该套件中 134 个棘手案例之一 1。
该归档文件通过单条 GNU tar 命令构建,包含 file、作为硬链接重命名为 café 的 ./file 以及 empty 三个条目 1。作者利用 --pax-option='delete=?time,size:=512' 参数强制将硬链接的大小设置为 512 字节(即一个 tar 头的大小),从而引发了解析分歧 1。GNU tar、BusyBox、Python、Go 和 Perl 选择忽略硬链接上的大小设置,正常提取出所有三个文件 1。然而,macOS 上的 bsdtar 遵循了 512 字节的设定,导致 file 的内容被替换为 empty 的 tar 头数据 1。此外,7-Zip 和 node-tar 等工具虽然识别出数据属于硬链接但跳过写入,仅保留 file 和 café 而丢失了 empty 1。Java Commons Compress、PHP PharData、RubyGems 和 R 语言则对该文件给出了不同的错误或非标准解释 1。Haskell 的 tar 库因字符串解码问题将文件名 café 显示为 café,而 .NET、Julia 和 uv 的 tar-codec 直接拒绝解析该文件 1。
A GNU tar archive named hardest.tar has been shown to produce eight distinct extraction results across various software tools, highlighting inconsistencies in tar format implementations. 1 This case was published by Haampie Stoppels on November 7, 2026, as part of the tar-minefield test suite, which includes 134 challenging scenarios designed to expose compatibility gaps and ambiguities in tar specifications. 1
The archive was constructed using a single GNU tar command containing three entries: file, empty, and a hard link originally named ./file but renamed to café. 1 By applying the option --pax-option='delete=?time,size:=512', the hard link's recorded size was forced to 512 bytes, matching the size of a standard tar header. 1 Different tools handle this anomaly in varying ways. GNU tar, BusyBox, Python, Go, and Perl ignore the specified size on the hard link and correctly extract all three files: file, café, and empty. 1 In contrast, bsdtar on macOS writes the 512 bytes directly, causing the content of file to be overwritten by the tar header data of empty. 1 Other tools such as 7-Zip and node-tar recognize the data belongs to the hard link but skip writing it, resulting in the loss of the empty file while preserving file and café. 1
Additional discrepancies appear in other environments. Java Commons Compress, PHP PharData, RubyGems, and the R language provide non-standard or erroneous interpretations of the same archive. 1 The Haskell tar library fails to decode the UTF-8 filename correctly, displaying café as café. 1 Meanwhile, .NET, Julia, and uv’s tar-codec refuse to parse the file entirely due to its structure. 1
评论
还没有评论,欢迎留下第一条。