avformat/asfdec_f: Add an additional check for the extradata size

Fixes: OOM
Fixes: 30066/clusterfuzz-testcase-minimized-ffmpeg_dem_ASF_fuzzer-6182309126602752

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 2c8cd4490a)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-02-07 21:50:03 +01:00
parent c8707132a9
commit 5e0ef4e2a9
1 changed files with 2 additions and 0 deletions

View File

@ -516,6 +516,8 @@ static int asf_read_stream_properties(AVFormatContext *s, int64_t size)
tag1 = avio_rl32(pb); tag1 = avio_rl32(pb);
avio_skip(pb, 20); avio_skip(pb, 20);
if (sizeX > 40) { if (sizeX > 40) {
if (size < sizeX - 40)
return AVERROR_INVALIDDATA;
st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40); st->codecpar->extradata_size = ffio_limit(pb, sizeX - 40);
st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size + st->codecpar->extradata = av_mallocz(st->codecpar->extradata_size +
AV_INPUT_BUFFER_PADDING_SIZE); AV_INPUT_BUFFER_PADDING_SIZE);