Repository navigation
fix(importer): reject malformed GPX containers instead of looping forever - #2991
Merged
Merged
Conversation
…ever A file entry whose data sectors lie before the entry made the sector scan revisit the same entry endlessly while allocating memory. The scan now only moves forward, sector pointers and file sizes are validated against the container, the decompressed size respects maxDecodingBufferSize and a score.gpif without root element is rejected as unsupported. Fixes #2967
6 of 9 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.
Note
AI-authored disclosure (
alphatab-ai-authored-v1)Portions of this content were authored by an AI agent. The agent has read
AGENTS.md and the human submitter accepts responsibility for
compliance with the rules in that document.
Issues
Fixes #2967
Proposed changes
A GPX (BCFS) file entry whose data sectors lie before the entry made
GpxFileSystemjump back to the entry and read it again, forever, allocating a new buffer each pass. Because import is synchronous, a 12 KB crafted file froze the caller and eventually ran it out of memory. The same applied to the .NET and Android builds.The fix is in the container layer:
UnsupportedFormatError. In C#/Kotlin these previously surfaced as index errors; in JS a negative offset silently read from the end of the buffer.importer.maxDecodingBufferSize(OverflowError, as for the other binary importers since 1.9.0 hardening: fix release-review findings across rendering, importers, player and packaging #2990), and a truncated compressed stream is rejected instead of failing with aRangeError.GpifParserrejects ascore.gpifwithout root element as unsupported instead of failing later with aTypeError.All 37
.gpxfiles intest-dataload byte-identically to before; none has a backward or out-of-range sector. New in-memory tests cover each rejected case, plus the issue's exact bytes throughScoreLoader.Checklist
AI authorship disclosure
(
alphatab-ai-authored-v1) is present at the top of this body, and I havepersonally reviewed every change and can explain each one
Further details