[FFmpeg-devel] [PATCH] avformat/mov: validate chunk_count vs stsc_data

Chris Cunningham chcunningham at chromium.org
Tue Feb 5 02:29:18 EET 2019


On Sat, Feb 2, 2019 at 3:55 AM Michael Niedermayer <michael at niedermayer.cc>
wrote:

> >  static inline int64_t mov_get_stsc_samples(MOVStreamContext *sc,
> unsigned int index)
> >  {
> > -    int chunk_count;
> > +    unsigned int chunk_count = 0;
> >
> >      if (mov_stsc_index_valid(index, sc->stsc_count))
> >          chunk_count = sc->stsc_data[index + 1].first -
> sc->stsc_data[index].first;
> > -    else
> > +    else if (sc->chunk_count >= sc->stsc_data[index].first)
> >          chunk_count = sc->chunk_count - (sc->stsc_data[index].first -
> 1);
>
> This construct occurs a 2nd time (in mov_build_index()) is this not
> affected?
>

Didn't notice it, but I think it would be affected. I'll leave this alone
for now, but I'm open to adding a mov_get_chunk_count helper to call from
both mov_build_index and mov_get_stsc_samples.


> mov_read_trak() contains a check for chunk_count and the first index(es)
> (obviously this is not catching this one but)
> is there a reason not to eliminate the inconsistancy at that or some other
> "early" point?
>

Agree this sounds better. Stand by for patch.


More information about the ffmpeg-devel mailing list