Files
rea/docs/reference
morluto 225a19ae7a feat(artifacts): inventory and extract stored and gzip-compressed tar archives (#14245)
* feat(artifacts): inventory and extract stored and gzip-compressed tar archives

Recognize POSIX ustar and GNU tar headers, plain or as the first block of
a gzip member, as the new tar artifact format, so Linux release tarballs
and Unity .unitypackage files inventory and extract like ZIP archives.

The tar reader walks every header once, applying pax path, linkpath and
size records, GNU long names and the ustar prefix. Regular files,
directories and symlinks are occurrences with typeflag, mode, owner,
mtime and link target; devices, FIFOs, hard links and sparse members
are traversal omissions. Gzip members are read by forward decompression
with an idle stream reused for in-order opens, and every decompressed
byte is charged to artifact_limits.expanded_bytes.

A later corrupt header, a truncated member or gzip stream, and non-zero
bytes after the end marker keep the members read so far with unknown
coverage and an explicit end_state; a first block with the ustar magic
and a bad checksum is refused with that reason.

Fixes #14177

* docs(compare): name tar-entry among the compared format metadata kinds

* fix(tar): keep complete members and header facts across tar edge cases

- Charge omitted devices, FIFOs and links to the retained-metadata allowance.
- Probe a small gzip tar without verifying its trailer, and feed the final
  trailer to zlib separately so data before a bad CRC stays readable;
  queue decompressed output so a later failure cannot drop it.
- Decode negative GNU base-256 numbers; only mtime may be negative.
- Apply pending pax records only to the next member, never to extension
  headers, and let an empty pax value delete the keyword.
- Push a member once its data is complete, then skip its padding.
- Treat a cut-off zero block as truncation, not an end marker.
- Stop with malformed partial coverage, not a refusal, when a later header
  declares an unsafe size.

* fix(tar): charge gzip expansion as zlib produces it

The decompressed-output queue charged the plaintext-work allowance only
when the reader took a chunk, so bytes queued for an idle reader were
not bounded by artifact_limits.expanded_bytes. Each chunk is now charged
in the data handler before it is queued; an exhausted allowance stops the
inflater, and the queued, already-charged bytes are served before the
limit failure.

* fix(tar): validate numeric pax records and probe gzip past its header fields

- A pax size, uid, gid or mtime record that does not parse now stops the
  walk as malformed at that member, keeping earlier members, instead of
  silently falling back to the header field.
- The gzip-wrapped tar probe skips the RFC 1952 FEXTRA, FNAME, FCOMMENT
  and FHCRC fields before applying its 2 KiB compressed-data bound, so a
  long name or comment no longer hides the archive.
2026-11-24 15:40:38 +00:00
..