Skip to content

Commit

Permalink
avformat/mov: Check samplesize and offset to avoid integer overflow
Browse files Browse the repository at this point in the history
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 <[email protected]>
(cherry picked from commit 53c1f5c)
Signed-off-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Apr 15, 2023
1 parent b84a46d commit d29a054
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libavformat/mov.c
Original file line number Diff line number Diff line change
Expand Up @@ -3948,6 +3948,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;
Expand Down

0 comments on commit d29a054

Please sign in to comment.