Skip to content

fix(torrent): open torrents whose metainfo holds over 100,000 values - #667

Merged
linroid merged 1 commit into
mainfrom
fix/torrent-large-v1-metainfo
Nov 14, 2026
Merged

linroid merged 1 commit into
mainfrom
fix/torrent-large-v1-metainfo

Conversation

@linroid

@linroid linroid commented Nov 14, 2026

Copy link
Copy Markdown
Owner

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 .torrent file: the v1 parser, the v2 sniff, the tracker tiers, and the defaults of TorrentV2Document.parse and TorrentV2Info.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 of library:torrent pass on the JVM, and the tests compile for iOS.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-14T03:56:45.843596Z f7d77fe PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@claude

claude Bot commented Nov 14, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@github-actions

Copy link
Copy Markdown
Contributor

Test Results

 2 270 files  + 5   2 298 suites  +5   57m 5s ⏱️ -37s
16 090 tests + 6  15 810 ✅ + 6  280 💤 ±0  0 ❌ ±0 
19 533 runs  +10  19 253 ✅ +10  280 💤 ±0  0 ❌ ±0 

Results for commit f7d77fe. ± Comparison against base commit aca4a27.

@linroid
linroid merged commit b9efaba into main Nov 14, 2026
15 checks passed
@linroid
linroid deleted the fix/torrent-large-v1-metainfo branch November 14, 2026 04:12
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