summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2023-02-20 19:19:32 +0100
committerMichael Niedermayer <michael@niedermayer.cc>2023-03-16 14:48:36 +0100
commitfa22608c46910b33a642fdc220470b19eb5bea52 (patch)
tree970b15fd156a0f93649b832c05a36c44d2a19731
parent52d055b34d09601b54c07f31220842c1fd90d150 (diff)
downloadffmpeg-fa22608c46910b33a642fdc220470b19eb5bea52.tar.gz
avformat/mov: Check samplesize and offset to avoid integer overflow
Fixes: signed integer overflow: 9223372036854775584 + 536870912 cannot be represented in type 'long' Fixes: 55844/clusterfuzz-testcase-minimized-ffmpeg_dem_MOV_fuzzer-510613920664780 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 53c1f5c2e28e54ea8174b196d5cf4a158907395a) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavformat/mov.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 2b1131b911..88fbfbcb5d 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4162,6 +4162,13 @@ static void mov_build_index(MOVContext *mov, AVStream *st)
if (keyframe)
distance = 0;
sample_size = sc->stsz_sample_size > 0 ? sc->stsz_sample_size : sc->sample_sizes[current_sample];
+ if (current_offset > INT64_MAX - sample_size) {
+ av_log(mov->fc, AV_LOG_ERROR, "Current offset %"PRId64" or sample size %u is too large\n",
+ current_offset,
+ sample_size);
+ return;
+ }
+
if (sc->pseudo_stream_id == -1 ||
sc->stsc_data[stsc_index].id - 1 == sc->pseudo_stream_id) {
AVIndexEntry *e;