Repository navigation
Conversation
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 206fb16fa2
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| var remaining = protocolLength - payloadLength | ||
| while (remaining > 0) { | ||
| val count = minOf(remaining, zeros.size.toLong()).toInt() | ||
| sha1.update(zeros, 0, count) |
There was a problem hiding this comment.
Bound hashing of virtual padding
When a hybrid document declares a very large valid power-of-two piece length and a tiny file followed by matching padding, TorrentV2Info.parse and TorrentHybridLayout.parse accept it, but this loop hashes every virtual byte in 4 KiB increments. For example, a one-byte payload with a 2^62-byte piece causes roughly 10^15 SHA-1 updates, effectively hanging verification despite receiving almost no payload. Enforce the runtime piece-length limit before constructing the verifier, or reject/cap protocolLength - payloadLength here.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in 8b365cd. TorrentPayloadVerifier now enforces the existing runtime 16 MiB piece ceiling before constructing the layout or hashing padding. Parsing can still describe larger protocol-valid dimensions. The regression constructs the one-byte/2^62-byte hybrid case and verifies immediate rejection, plus rejection above the ceiling and acceptance at the ceiling. All five focused verifier tests and the native-runtime dependency guard pass. The fix is also propagated into #176.
|
Superseded by #233 (V2 layout and verified storage) in the consolidated eight-PR stack for #162. The replacement preserves this PR's code and subsequent fixes; its description links the original head and review discussions. The only additional consolidation fix is the CI-discovered listener cancellation regression, documented on the replacement. All eight replacements have passed their required CI checks. Closing without merging. This branch and its discussions remain available for reference. Review index: #162 (comment) |
Authenticate streamed v2 pieces against the imported file root or validated piece-layer hash before storage can commit them. Short final pieces expand with zero-hash subtrees to the required layer; hybrid pieces must also match SHA-1, including virtual padding. Hashing retains bounded state without a full-piece buffer.
Stack: based on #174, advancing #162 step 06. This is the integrity boundary; storage staging, durable commit, generation barriers and runtime v2 download integration remain pending.
Validation: 350 torrent JVM tests passed with no failures or skips, including both existing pinned-client v1 conformance scenarios. The native-runtime dependency guard passed. New tests cover short piece-layer tails, smaller file-root trees, streaming input validation, conflicting hybrid hashes and virtual padding. These tests do not establish v2 client interoperability.