aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-11-08 00:08:35 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-10 16:04:26 +0200
commit381f3d9fac6a35e0a928f5ecaff1ccadd6498a0c (patch)
treef6f28f7c4a4b6f336ea27a9cb519706ed0bdb7c2
parenta6c91db54cbc8c0234008810a55c7fb65d9cbfaf (diff)
downloadffmpeg-381f3d9fac6a35e0a928f5ecaff1ccadd6498a0c.tar.gz
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@niedermayer.cc> (cherry picked from commit 386faeda5ff1924c17766248ce19528dbf90cf15) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/cfhd.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/libavcodec/cfhd.c b/libavcodec/cfhd.c
index fcd1902471..7595c10887 100644
--- a/libavcodec/cfhd.c
+++ b/libavcodec/cfhd.c
@@ -550,6 +550,12 @@ static int cfhd_decode(AVCodecContext *avctx, void *data, int *got_frame,
s->peak.level = 0;
} else if (tag == -74 && 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);