diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2020-10-22 23:08:13 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2020-11-29 16:10:55 +0100 |
commit | 5eed718087f2ba307a3d1d294016d2ebae9230f3 (patch) | |
tree | dc2925214925e8af649a577d577ef31dc90bdc44 /libavformat/cafdec.c | |
parent | 4bdb7966fac87fdbf76f4828a3fbe14fd874679c (diff) | |
download | ffmpeg-5eed718087f2ba307a3d1d294016d2ebae9230f3.tar.gz |
avformat/cafdec: Check that bytes_per_packet and frames_per_packet are non negative
These fields are not signed in the spec (1.0) so they cannot be negative
Changing bytes_per_packet to unsigned would not solve this as it is exported
as block_align which is signed
Fixes: Infinite loop
Fixes: 26492/clusterfuzz-testcase-minimized-ffmpeg_dem_CAF_fuzzer-5632087614554112
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavformat/cafdec.c')
-rw-r--r-- | libavformat/cafdec.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libavformat/cafdec.c b/libavformat/cafdec.c index 3bf1fa64bc..06069f2610 100644 --- a/libavformat/cafdec.c +++ b/libavformat/cafdec.c @@ -79,6 +79,9 @@ static int read_desc_chunk(AVFormatContext *s) st->codecpar->channels = avio_rb32(pb); st->codecpar->bits_per_coded_sample = avio_rb32(pb); + if (caf->bytes_per_packet < 0 || caf->frames_per_packet < 0) + return AVERROR_INVALIDDATA; + /* calculate bit rate for constant size packets */ if (caf->frames_per_packet > 0 && caf->bytes_per_packet > 0) { st->codecpar->bit_rate = (uint64_t)st->codecpar->sample_rate * (uint64_t)caf->bytes_per_packet * 8 |