1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-28 20:53:54 +02:00

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>
(cherry picked from commit 5eed718087)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2020-10-22 23:08:13 +02:00
parent 4371d51f1b
commit b8fe632a73

View File

@ -79,6 +79,9 @@ static int read_desc_chunk(AVFormatContext *s)
st->codec->channels = avio_rb32(pb);
st->codec->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->codec->bit_rate = (uint64_t)st->codec->sample_rate * (uint64_t)caf->bytes_per_packet * 8