TTPF: reject backwards chunk ranges and excessive padding #14
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
good first issue
help wanted
invalid
question
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Ahmet-Dedeler--bcpack-rs!14
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-14"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@yefan911 on GitHub · 2026-11-26 18:21 UTC · original
yefan911:fix/ttpf-chunk-ranges→master· +84 −3 · 1 files · 1 commits · openStore::from_bytescurrently clamps backwards physical and virtual chunk ranges to zero withsaturating_sub. It also accepts padding larger than the chunk, whichdata_lenthen hides with another saturating subtraction. Malformed chunk tables consequently look like valid empty chunks; backwards virtual offsets also violate the ordering expected bylocate.Reject these inconsistent ranges with
InvalidDataerrors identifying the chunk. Keep valid zero-length ranges and fully padded chunks accepted. Physical EOF checks remain inchunk_bytes, preserving the existing synthetic high-offset metadata test and its lazy bounds validation.Validation on Windows x86-64 / Rust 1.99.1:
cargo test --locked: 34 unit/integration tests and one doctest passed.cargo clippy --all-targets --all-features --locked -- -D warnings: passed.git diff --check: passed. Fullcargo fmt -- --checkreports existing formatting differences; comparing formatter corrections forttpf.rsbefore and after this patch shows the same three pre-existing changes and no new formatting differences. No unrelated formatting edits included.No game files or retail checks used. New fixtures contain only generated headers and zero-filled synthetic bytes. No dependencies or generated tables changed.
AI-assisted: GPT-6.1 Sol.
Summary by CodeRabbit
@coderabbitai[bot] on GitHub · 2026-11-26 18:21 UTC · original · edited 2026-11-26 18:23 UTC
No actionable comments were generated in the recent review.
Walkthrough
Store::from_bytesnow rejects backwards file or virtual ranges and padding larger than a chunk’s stored length. Tests cover valid and invalid ranges, empty and fully padded chunks, and reads beyond file bounds.Changes
Chunk range validation
src/ttpf.rsStore::from_bytesuses checked subtraction for file and virtual ranges and rejects padding larger than the stored range. Tests cover ordered, backwards, empty, fully padded, and out-of-file chunks.Estimated code review effort: 2 (Simple) | ~10 minutes
Change: Bug fix
Suggested reviewers:
ahmet-dedelerMerge Risk:
Minimal · up to
7b30dThis change makes the parser reject malformed chunk ranges and excessive padding instead of treating them as empty chunks. Valid zero-length and fully padded chunks are still accepted. No merge-blocking risk was found.
Pre-merge checks:
4
Full details: Title check
Explanation
The title names the two main changes: rejecting backwards chunk ranges and rejecting excessive padding in the TTPF parser. The raw summary confirms that Store::from_bytes now rejects backwards file or virtual ranges and padding larger than the chunk length, so the title matches the changeset. It is specific and concise, and it uses the TTPF scope prefix that the objectives also use.
Finishing Touches
Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
Share
9b8a9910-18d7-48a7-98f1-44dd43d00eb7Reviewing files that changed from the base of the PR and between
7b2b42122cand7b30d01735.src/ttpf.rsIncluded review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.