Repository navigation
fix(torrent): open torrents whose metainfo holds over 100,000 values - #667
Merged
Merged
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
Code reviewNo issues found. Checked for bugs and CLAUDE.md compliance. |
Contributor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A torrent within the documented limit of 10,000 files was refused with "Bencode structure exceeds limits" once its metainfo held more than 100,000 bencode values, which deep folders reach well below the file limit (9,000 files eleven folders deep, for example).
The v1 parser already allowed 1,000,000 values, but every path into it first sniffs the metainfo as v2 (
resolveV2Metainfo) and reads its trackers (sourceTrackerTiers) with the bencode parser's default of 100,000, so v1 torrents never reached their own parser. V2 and hybrid documents had the same 100,000 default throughout.Fix
One limit,
MAX_METAINFO_NODES(1,000,000), for every reader of a.torrentfile: the v1 parser, the v2 sniff, the tracker tiers, and the defaults ofTorrentV2Document.parseandTorrentV2Info.parse, so resolving, listing files, starting and resuming agree. The 4 MiB size limit still bounds the work.Testing
TorrentLargeMetainfoTest: a v1 torrent of 9,000 deep files lists its files and trackers (failed before with the error above), and so does a v2 torrent of 9,000 deep files. The metainfo, source and magnet suites oflibrary:torrentpass on the JVM, and the tests compile for iOS.