avcodec/mlpdec: add max channels check

Fixes: out of array access
Fixes: 51648/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TRUEHD_fuzzer-4644322217164800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2022-09-30 00:44:31 +02:00
parent 77164b2344
commit f1f78e3cf4
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64
1 changed files with 3 additions and 0 deletions

View File

@ -547,6 +547,9 @@ static int read_restart_header(MLPDecodeContext *m, GetBitContext *gbp,
return AVERROR_PATCHWELCOME;
}
if (max_channel + 1 > MAX_CHANNELS || max_channel + 1 < min_channel)
return AVERROR_INVALIDDATA;
s->min_channel = min_channel;
s->max_channel = max_channel;
s->coded_channels = ((1LL << (max_channel - min_channel + 1)) - 1) << min_channel;