Skip to content

Commit b37581a

Browse files
authored
flac: Fix invalid channel count fuzzer crash. (pdeljanov#419)
Ensure the channel count for a decoded FLAC frame matches the channel count of the output buffer (derived from the stream info).
1 parent 46592f1 commit b37581a

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

symphonia-bundle-flac/src/decoder.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,17 @@ impl FlacDecoder {
120120
self.buf.clear();
121121
self.buf.render_reserved(Some(header.block_num_samples as usize));
122122

123+
let frame_channels = match header.channel_assignment {
124+
ChannelAssignment::Independant(c) => c as usize,
125+
ChannelAssignment::LeftSide
126+
| ChannelAssignment::MidSide
127+
| ChannelAssignment::RightSide => 2,
128+
};
129+
130+
if frame_channels != self.buf.spec().channels.count() {
131+
return decode_error("flac: frame channel count does not match stream info");
132+
}
133+
123134
// Only Bitstream reading for subframes.
124135
{
125136
// Sub-frames don't have any byte-aligned content, so use a BitReader.

0 commit comments

Comments
 (0)