avformat/bintext: Check width

Fixes: division by 0
Fixes: 26780/clusterfuzz-testcase-minimized-ffmpeg_dem_ADF_fuzzer-5117945027756032
Fixes: 26998/clusterfuzz-testcase-minimized-ffmpeg_dem_ADF_fuzzer-5119352359354368

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 f6dc285fb5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-10-31 13:51:47 +01:00
parent 316c6d1645
commit a21ad9701f
1 changed files with 2 additions and 0 deletions

View File

@ -291,6 +291,8 @@ static int adf_read_header(AVFormatContext *s)
bin->fsize = avio_size(pb) - 1 - 192 - 4096; bin->fsize = avio_size(pb) - 1 - 192 - 4096;
st->codecpar->width = 80<<3; st->codecpar->width = 80<<3;
ff_sauce_read(s, &bin->fsize, &got_width, 0); ff_sauce_read(s, &bin->fsize, &got_width, 0);
if (st->codecpar->width < 8)
return AVERROR_INVALIDDATA;
if (!bin->width) if (!bin->width)
calculate_height(st->codecpar, bin->fsize); calculate_height(st->codecpar, bin->fsize);
avio_seek(pb, 1 + 192 + 4096, SEEK_SET); avio_seek(pb, 1 + 192 + 4096, SEEK_SET);