avformat/paf: Check for EOF before allocation in read_header()

Fixes: OOM
Fixes: 26584/clusterfuzz-testcase-minimized-ffmpeg_dem_PAF_fuzzer-5172661183053824

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit bcb1e9d3b9)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2021-01-20 00:11:34 +01:00
parent 00c664f10e
commit e8f9a3690d
1 changed files with 4 additions and 0 deletions

View File

@ -136,6 +136,10 @@ static int read_header(AVFormatContext *s)
p->start_offset = avio_rl32(pb); p->start_offset = avio_rl32(pb);
p->max_video_blks = avio_rl32(pb); p->max_video_blks = avio_rl32(pb);
p->max_audio_blks = avio_rl32(pb); p->max_audio_blks = avio_rl32(pb);
if (avio_feof(pb))
return AVERROR_INVALIDDATA;
if (p->buffer_size < 175 || if (p->buffer_size < 175 ||
p->max_audio_blks < 2 || p->max_audio_blks < 2 ||
p->max_video_blks < 1 || p->max_video_blks < 1 ||