Tar archive quadratic time. 2022

By Xah Lee. Date: . Last updated: .

Why tar archive sucks

Amazing article. After 30 years, now i know the unix tar format, and how bad it is.

• No indexing of files. You need to read the entire archive to know what files are in it.

• Via 3 extensions over decades, UStar, pax file format, gnu tar, the format became very convoluted. quote: .

needs to support 5 different ways of reading the file path, 5 different ways of reading the link path, and 3 different ways of reading the file size

• Gnu tar, in order to prevent security problem of extracting file outside the current dir, it uses a very inefficient algorithm and data structure, making it quadratic time slow.

For every hard link, we walk the list of all delayed links. But it actually gets worse; ... So for all "normal" hard links, it has to go through the entire linked list of delayed links twice.

• But if you use option “tar -P” (or --absolute-paths), it bypass this but mean malicious tar file can put files anywhere on your system.

tar Martin Dorum 2026-07-08 2aa1c ll
tar Martin Dorum 2026-07-08 2aa1c ll

Gnu tar fixed the quadratic problem

note: bsd tar doesn't have this problem. gnu tar fixed the quadratic time problem.

gnu tar 2026-08-15 2c3de ll
gnu tar 2026-08-15 2c3de ll

unix tar