Skip to content

skip a torrent file that failed to parse - #2520

Merged
orignal merged 1 commit into
PurpleI2P:opensslfrom
pobregat0:torrent-skip-invalid
Aug 25, 2026
Merged

skip a torrent file that failed to parse#2520
orignal merged 1 commit into
PurpleI2P:opensslfrom
pobregat0:torrent-skip-invalid

Conversation

@pobregat0

Copy link
Copy Markdown
Contributor

A follow-up to #2519, and a correction of what I wrote there.

That change refuses unsafe names, and it does keep files inside the torrents folder - checked with crafted torrent files carrying "..", "/etc", a name of "../../evil" and a reserved Windows name: nothing was written outside. But my description claimed such a torrent "fails to parse entirely, rather than being partially accepted", and that part was not true. The parsing stops, yet the half built torrent was still added: the router created directories for those torrents and left a stray file.bin.part in the torrents folder.

Torrent::IsValid is added - a torrent needs a name, a piece length and either a length or a list of files - and ReadTorrentFile now skips anything that does not pass, with a line in the log.

Checked again with the same five files, four unsafe and one normal. Before: four "unsafe" lines, and the directories escape, absolute, good and normal appear along with file.bin.part. After: four "unsafe" lines each followed by "Invalid torrent file ... Skipped", only the directory of the legitimate torrent is created, and nothing else appears.

Builds without warnings, unit tests pass, C++17 syntax check is fine.

@orignal
orignal merged commit dd8ef88 into PurpleI2P:openssl Aug 25, 2026
15 checks passed
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.

2 participants