[FFmpeg-cvslog] avcodec/cfhd: check peak.offset

Michael Niedermayer git at videolan.org
Fri Jan 29 20:37:28 EET 2021


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Nov  8 00:08:35 2020 +0100| [386faeda5ff1924c17766248ce19528dbf90cf15] | committer: Michael Niedermayer

avcodec/cfhd: check peak.offset

Fixes: signed integer overflow: -2147483648 - 4 cannot be represented in type 'int'
Fixes: 26907/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CFHD_fuzzer-5746202330267648

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=386faeda5ff1924c17766248ce19528dbf90cf15
---

 libavcodec/cfhd.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index aae6bd78db..dfd56ae6ed 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -617,6 +617,12 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
             s->peak.level   = 0;
         } else if (tag == -PeakLevel && s->peak.offset) {
             s->peak.level = data;
+            if (s->peak.offset < 4 - bytestream2_tell(&s->peak.base) ||
+                s->peak.offset > 4 + bytestream2_get_bytes_left(&s->peak.base)
+            ) {
+                ret = AVERROR_INVALIDDATA;
+                goto end;
+            }
             bytestream2_seek(&s->peak.base, s->peak.offset - 4, SEEK_CUR);
         } else
             av_log(avctx, AV_LOG_DEBUG,  "Unknown tag %i data %x\n", tag, data);



More information about the ffmpeg-cvslog mailing list