Skip to content

Fix four review findings left open on merged PRs (#318, #343, #347, #356) - #370

Merged
xbmc4lyfe merged 3 commits into
mainfrom
codex-thread-fixes
Nov 30, 2026
Merged

xbmc4lyfe merged 3 commits into
mainfrom
codex-thread-fixes

Conversation

@xbmc4lyfe

@xbmc4lyfe xbmc4lyfe commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes four review findings that were still present on main. Each one has a test that fails before its fix and passes after it.

1. ZIP 7z cut mode: a cut member that checks out was reported verified (PRRT_kwDOVi_ME8684gCe, #343)

Archive::read_truncated_at (src/zip.rs) now checks gap_crossed when a read succeeds. A stored streamed member (flag 0x0008, CRC and sizes 0) cut before its descriptor, with no bytes or with 9d 0a d9 6d (CRC32 0), now fails as Truncated under SevenZip + Emit, as it already did under Withhold. The whole-archive run (extract::run) had the same gap: it counted such a member as an extracted file. It now fails it at the gap too, keeping the file with keep_broken.
Test: tests/seven_zip_cut_member.rs::a_cut_stored_streamed_member_whose_bytes_match_crc_0_still_fails_as_cut covers the empty, CRC-0 and abcd payloads. It runs SelectedEntry under Emit and Withhold, and extract::run in 7z mode and with salvage alone.
After a read that checks out, the data descriptor counts as part of the member only when it is the only source of the member's CRC and sizes: the last member of a local walk with no directory (gap_crossed_after_read). Otherwise only the data range is checked. So a whole streamed member whose descriptor alone sits in a missing volume, with a central directory giving its CRC and sizes, still extracts, as 7-Zip 26.06 extracts it (found in review; the first push of this PR regressed it).
Test: tests/zip_split_extract.rs::a_missing_volume_holding_only_a_data_descriptor_leaves_its_member_whole. In an Info-ZIP split with s.z02 (holding only a.txt's descriptor) missing, both members extract in 7z mode and with salvage alone, and a selected read of a.txt returns the same bytes.

2. 7z verify_next_header didn't charge the whole header to header_bytes (PRRT_kwDOVi_ME869VbS5, leftover of PRRT_kwDOVi_ME869VWrc, #356)

parse_next_header (src/map/sevenzip.rs) now charges the 32-byte signature header plus the next header before parsing, and an encoded header's packed stream before decoding, as the member map's walk does. Verify and the map now agree on the limit.
Test: tests/sevenzip_headers.rs::verify_and_the_member_map_agree_on_the_header_bytes_limit finds the map's smallest accepted limit for store_method.7z (151) and store_method_enc_headers.7z (283). Verify passes at that limit and fails one byte under it.

3. A cut RAR 4.x header naming an unsupported method or version replaced an existing file (PRRT_kwDOVi_ME869WhMZ, #347)

blocked in src/rar5/session/selection/extraction.rs now covers a cut header (HeaderCut::Header) whose rar4_unsupported() is set. Before, keep_broken published an empty file over an existing one under Overwrite::Always.
Test: tests/rar_cut_header.rs::a_cut_rar4_header_of_an_unsupported_method_or_version_keeps_the_existing_file cuts latest_winrar.rar at 58 and sets method 0x36 or version 99. The existing file stays and the member is still reported failed.

4. The default 7z parallel LZMA2 budget ignored a container's memory limit (PRRT_kwDOVi_ME868ndWQ, #318)

default_lzma2_parallel_bytes (src/sevenzip.rs) now uses usable_memory(): on Linux, the lower of physical memory and the cgroup limit (v2 /sys/fs/cgroup/memory.max, else v1 /sys/fs/cgroup/memory/memory.limit_in_bytes). It reads at most 64 bytes, parses them with a checked pure function (max, v1's near-2^63 "no limit", 0, garbage and empty all give no limit) and caches the result once. The doc comment and docs/7z-extract.md are updated.
Follow-up, not done here: only the cgroup mount root is read. Resolving the process's own cgroup through /proc/self/cgroup and taking the minimum limit up the tree would also catch systemd MemoryMax and limits set on parent cgroups.
Tests: unit tests in sevenzip::cgroup_memory_tests cover v2 numbers, max, v1 huge values, overflow, garbage, signs, empty and 0, and check that usable memory is no more than physical memory.

Checks run (macOS arm64)

  • cargo fmt --all -- --check
  • cargo clippy --workspace --all-targets --locked -- -D warnings, plain and with --features persistent-partials
  • lib unit tests plus zip, zip_split_extract, declared_size, emit_cut_archive, feed_decoder_7z, keep_broken, member_map_7z, progressive_salvage, rar4_stored, rar_cut_header, rar_salvage, seven_zip_cut_member, seven_zip_strict, sevenzip_extract, sevenzip_headers, sevenzip_lzma2_threads, sevenzip_print, unverified_output, zip_salvage_truncated, container_rebuild_headers, container_rebuild, compat_options: all pass

Not run: the full /ci-local. The clean-room review compiled the cgroup code for x86_64-unknown-linux-musl under clippy -D warnings.

Implemented clean-room, from the zipfast repo and observed behaviour only.

🤖 Generated with Claude Code

https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi

xbmc4lyfe and others added 3 commits November 30, 2026 11:34
)

- zip (7z cut mode, Emit): a cut stored streamed member whose bytes match its CRC (none, or bytes with CRC32 0)
  now fails as truncated instead of reading as verified: a successful read is checked against the gap too.
- 7z verify_next_header: the signature header, the next header and an encoded header's packed stream are charged
  to header_bytes as the member map charges them, so verify and the map agree on the limit.
- RAR 4.x cut file header whose fields name an unsupported method or unpack version is blocked like a nameless one:
  keep_broken no longer publishes an empty file over an existing one.
- 7z default lzma2_parallel_bytes: on Linux, the lower of physical memory and the cgroup memory limit (v2
  memory.max, v1 memory.limit_in_bytes), parsed with a checked pure function and read once.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
The whole-archive run of a cut ZIP counted a stored streamed member whose bytes (or lack of them) match its CRC as
extracted; it now fails at the gap as a member that doesn't check out does (kept with keep_broken).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
…is the sole source of CRC and sizes

A whole streamed member whose data descriptor alone sits in a missing volume, with a central directory stating its
CRC and sizes, extracts again (7-Zip 26.06 extracts it); the descriptor is part of the member after a good read only
for the last member of a local walk with no directory. The cut CRC-0 members still fail.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LG44gYJFfVCupfunL2idYi
@xbmc4lyfe

Copy link
Copy Markdown
Collaborator Author

Local CI (full, all gates: fmt, clippy ×2, tests ×2, doctests ×2) passed at 775db92 on linux x86_64 (rustyget-x86-q), linux arm64 (rustyget-arm-g) and macOS arm64. Rebased onto 2a88710, which changes only AGENTS.md and CLAUDE.md; the code tree is identical to the gated head.

@xbmc4lyfe
xbmc4lyfe merged commit e48533a into main Nov 30, 2026
0 of 7 checks passed
@xbmc4lyfe
xbmc4lyfe deleted the codex-thread-fixes branch November 30, 2026 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant