Files
pad/internal
xarmian 3fe40aeff7 fix(import): bound the work a single bundle import can do (#1735)
* fix(import): bound a bundle's decompressed bytes and entry count (BUG-3354)

The 2 GiB cap applied to the compressed body only. The tar stream now
counts every decompressed byte against 4x the body cap plus room for
both metadata files, refuses an entry declaring more than the budget
has left before inflating it, and stops after 100,000 entries. Each
answers 413 bundle_too_large through the existing reject path, which
rolls back a workspace the bundle had already minted.

* fix(import): charge sparse entries logically and count extension header blocks (BUG-3354)

Codex r1: a sparse entry's holes are synthesized above the counted stream,
and PAX/GNU extension headers are consumed inside Next where the entry count
cannot see them. Declared sizes now draw on their own logical budget, the
header blocks each Next reads are capped, and skipped non-regular entries are
drained by the loop so that count stays headers only.

* fix(import): refuse a bundle entry with a negative declared size (BUG-3354)

Codex r2: archive/tar accepts a negative base-256 size on some entry types,
and charging one raised the logical budget it was charged to.

* fix(import): enforce the tar header limit inside each Next call (BUG-3354)

Codex r3: tar.Reader.Next walks a whole PAX/GNU extension chain before it
returns, so a header-block limit checked afterwards refused the bundle only
after all of that work. The counting reader now carries a header window
armed around each Next and fails the read that would pass it.

* fix(import): the decompressed-size 413 states its limit and the setting that raises it (BUG-3354)
2026-10-02 16:28:58 -04:00
..