Repository navigation
audio: ffmpeg_dec: reject frames whose channel count differs from sink - #11351
Open
Shrusti-pk wants to merge 1 commit into
Open
Shrusti-pk wants to merge 1 commit into
Shrusti-pk wants to merge 1 commit into
Conversation
ffmpeg_dec_convert_frame() interleaves a decoded AVFrame using the sink channel count, but the frame's own channel count comes from the compressed bitstream and is never compared with it. When the stream has fewer channels than the sink, e.g. a mono FLAC or MP3 played into a stereo pipeline, every conversion path reads past the decoded frame: the interleaved copies read nb_samples * sink_channels samples from a buffer holding nb_samples * stream_channels, and the planar paths use frame->data[ch] for channels the frame does not have. With a 4608-sample mono FLAC frame and a stereo S32 sink this is a 9216 byte heap over-read past the frame buffer, and the bytes read are written to the sink as PCM. Return -EINVAL when frame->ch_layout.nb_channels does not match the sink. The decode loop already drops a frame the converter rejects.
Shrusti-pk
requested review from
dbaluta,
kv2019i,
lbetlej,
lgirdwood,
mmaka1 and
plbossart
as code owners
October 23, 2026 15:05
Collaborator
|
Can one of the admins verify this patch?
|
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.
ffmpeg_dec_convert_frame() reads each decoded frame using the sink's channel count. The frame's own channel count comes from the compressed stream and is never compared with the sink's:
The converter now returns -EINVAL on a channel mismatch before reading anything, and the decode loop already drops a frame it rejects. With the fix, output for streams whose channel count matches the sink (mono to mono, stereo to stereo, S16 and S32) is byte-identical to before. I added no in-tree test because nothing in tree builds ffmpeg_dec against libavcodec yet (TESTING.md).