Tar: Missing support for Pax extended file headers #629

Open
opened 2026-01-29 22:14:57 +00:00 by claunia · 0 comments
Owner

Originally created by @cjsut on GitHub (Apr 25, 2024).

The Tar implementation has support for long file names using the 'L' type flag and Pax extended global headers using the 'g' type flag, but not Pax extended file headers using the 'x' type flag.

Some implementations of the tar format use these headers for long (> 100 character) file names (we ran into this with NPM packages, for example). As currently implemented, SharpCompress exposes the archiver-implementation-defined name in Entry.Key (which may not be unique due to truncation) for such archives since it is not aware of the Pax extended header format; this leads to issues like duplicate and non-representative file names when attempting to extract these archives.

See this reference for the Pax archive format. Implementation would require adding support for the 'x' header type flag, and overwriting or adding various extended fields specified by this format. Notably some of these extended fields are already supported, but others offer opportunity for improved archive support (file encoding, for example).

Originally created by @cjsut on GitHub (Apr 25, 2024). The Tar implementation has support for [long file names using the `'L'` type flag](https://github.com/adamhathcock/sharpcompress/blob/49ce17b7598466e7bb56200461dfbfe91c175f52/src/SharpCompress/Common/Tar/Headers/EntryType.cs#L14) and [Pax extended global headers using the `'g'` type flag](https://github.com/adamhathcock/sharpcompress/blob/49ce17b7598466e7bb56200461dfbfe91c175f52/src/SharpCompress/Common/Tar/Headers/EntryType.cs#L17), but not [Pax extended file headers using the `'x'` type flag](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13). Some implementations of the tar format use these headers for long (> 100 character) file names (we ran into this with NPM packages, for example). As currently implemented, SharpCompress exposes the archiver-implementation-defined name in `Entry.Key` (which may not be unique due to truncation) for such archives since it is not aware of the Pax extended header format; this leads to issues like duplicate and non-representative file names when attempting to extract these archives. See [this reference for the Pax archive format](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13). Implementation would require adding support for the `'x'` header type flag, and overwriting or adding [various extended fields specified by this format](https://pubs.opengroup.org/onlinepubs/9699919799/utilities/pax.html#tag_20_92_13_03). Notably some of these extended fields are already supported, but others offer opportunity for improved archive support (file encoding, for example).
claunia added the enhancementup for grabs labels 2026-01-29 22:14:57 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#629