decoder/mad: bound Xing seek table allocations - #2555
Open
acts-1631 wants to merge 2 commits into
Open
Conversation
Member
|
This commit mixes several distinct changes that should be separate commits. |
The mad decoder uses the Xing frame count to size its seek tables. A small input can claim millions of frames and request a disproportionate amount of memory. Ignore a frame count which cannot fit in the known input, even if each frame contains only a four-byte MPEG header. For an unknown-size stream, retain the conservative estimate from FileSizeToSongLength().
The mad decoder's seek tables are allocated from a value derived from the input. AllocateBuffers() is noexcept, so a failed allocation would terminate MPD. Use nothrow allocation and return failure to RunDecoder(). Free the first table if allocating the second fails.
acts-1631
force-pushed
the
fix/mad-xing-frame-count
branch
from
August 2, 2026 13:08
a1fe0ad to
4a2c495
Compare
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.
DecodeFirstFrame() uses the frame count from a Xing header as
max_frames. RunDecoder() then calls AllocateBuffers(), which eagerly
allocates frame_offsets and times arrays using that count.
The existing limit accepts 8,388,608 frames. On x86_64, the two arrays
request about 192 MiB. A crafted 1,189-byte MPEG file can supply this
count, and allocation failure terminates MPD because AllocateBuffers()
is noexcept.
Ignore Xing frame counts that cannot fit within the input even if every
frame were only a four-byte MPEG header. Unknown-size streams retain
the conservative estimate from FileSizeToSongLength(). Also use
nothrow allocation and clean up partial allocations so a remaining
failure stops this decoder instance instead of terminating MPD.