Credit ffmpeg team - security fix for ffmpeg 5.1
[goodguy/cinelerra.git] / cinelerra-5.1 / thirdparty / src / ffmpeg-5.1.patch6
1 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/blobdiff_plain/30bd4831e6213cee64ed950d69d1732194cc6464..6f53f0d09ea4c9c7f7354f018a87ef840315207d:/libavformat/mov.c
2
3 diff --git a/libavformat/mov.c b/libavformat/mov.c
4 index a644f9ac62..2b1131b911 100644
5 --- a/libavformat/mov.c
6 +++ b/libavformat/mov.c
7 @@ -3949,8 +3949,11 @@ static int build_open_gop_key_points(AVStream *st)
8  
9      /* Build an unrolled index of the samples */
10      sc->sample_offsets_count = 0;
11 -    for (uint32_t i = 0; i < sc->ctts_count; i++)
12 +    for (uint32_t i = 0; i < sc->ctts_count; i++) {
13 +        if (sc->ctts_data[i].count > INT_MAX - sc->sample_offsets_count)
14 +            return AVERROR(ENOMEM);
15          sc->sample_offsets_count += sc->ctts_data[i].count;
16 +    }
17      av_freep(&sc->sample_offsets);
18      sc->sample_offsets = av_calloc(sc->sample_offsets_count, sizeof(*sc->sample_offsets));
19      if (!sc->sample_offsets)
20 @@ -3969,8 +3972,11 @@ static int build_open_gop_key_points(AVStream *st)
21      /* Build a list of open-GOP key samples */
22      sc->open_key_samples_count = 0;
23      for (uint32_t i = 0; i < sc->sync_group_count; i++)
24 -        if (sc->sync_group[i].index == cra_index)
25 +        if (sc->sync_group[i].index == cra_index) {
26 +            if (sc->sync_group[i].count > INT_MAX - sc->open_key_samples_count)
27 +                return AVERROR(ENOMEM);
28              sc->open_key_samples_count += sc->sync_group[i].count;
29 +        }
30      av_freep(&sc->open_key_samples);
31      sc->open_key_samples = av_calloc(sc->open_key_samples_count, sizeof(*sc->open_key_samples));
32      if (!sc->open_key_samples)
33 @@ -3981,6 +3987,8 @@ static int build_open_gop_key_points(AVStream *st)
34          if (sg->index == cra_index)
35              for (uint32_t j = 0; j < sg->count; j++)
36                  sc->open_key_samples[k++] = sample_id;
37 +        if (sg->count > INT_MAX - sample_id)
38 +            return AVERROR_PATCHWELCOME;
39          sample_id += sg->count;
40      }
41