Repository navigation
fix: Stop deeply nested Matroska SimpleTags from overflowing the stack - #151
Merged
Merged
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #151 +/- ##
==========================================
+ Coverage 93.06% 93.08% +0.01%
==========================================
Files 334 335 +1
Lines 70883 71027 +144
Branches 7468 7477 +9
==========================================
+ Hits 65966 66112 +146
Misses 2911 2911
+ Partials 2006 2004 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This was referenced Nov 22, 2026
decriptor
force-pushed
the
fix/matroska-cues-depth
branch
from
November 22, 2026 06:17
ab82f19 to
623fd4d
Compare
Owner
Author
|
Review: 0 findings at 623fd4d. (Independent review; the coordinator wrote this PR.) What was checked:
|
9 of 12 tasks
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.
Description
MatroskaFile.ReadSimpleTagandSimpleTag.Renderrecursed once per nesting level. A crafted file could make that depth anything, soMatroskaFile.Read(andMediaFile.Read) ended the process with a stack overflow, which no caller can catch.MaxSimpleTagDepth).SimpleTag.KeptChildren, and a save writes it back unchanged after the parsed children. Nothing is lost, and no tag mapping reads deeper than two levels.Cues: this PR first also bounded the Cues walker. That half was dropped on the rebase, because main now walks Cues only along the spec paths (from #149, merged with #142). The Cues tests are kept; both pass on main's walker.
Motivation and Context
On main, a file with SimpleTags nested 100,000 deep (about 1 MB) crashes on open. One file in the review corpus (
st100000.mkv) already does, and it still crashed after #142 merged.Fixes #150
Type of Change
Checklist
dotnet test)Testing
Read_SimpleTagsNestedDeep_DoesNotOverflowAndSaveKeepsTheNesting(100,000 deep): overflows the stack on main, passes here. It also checks that the stored bytes below the parse depth occur exactly once in the saved file.Save_SimpleTagsAtAndPastTheParseDepth_KeepOnlyTheDeeperOnesAsStored(rows 62–69, 8-octet sizes) pins the cap exactly:<→<=turns 10 red;KeptChildrenturns 11 red each.Additional Notes
MatroskaTag.CopyTagcopies only top-level SimpleTags, which never holdKeptChildrenwhile the cap is above 1, so no copy path loses the kept bytes.