[FFmpeg-devel] [PATCH v2 08/12] lavc/frame_thread_encoder: avoid assigning a whole AVCodecContext

Anton Khirnov anton at khirnov.net
Sun Mar 24 13:23:32 EET 2024


Quoting Andreas Rheinhardt (2024-03-24 12:10:24)
> Anton Khirnov:
> > Quoting Andreas Rheinhardt (2024-03-24 11:19:19)
> >> Anton Khirnov:
> >>> Quoting Andreas Rheinhardt (2024-03-23 15:11:59)
> >>>> 1. The earlier code would just work in case the user used a smaller
> >>>> number of elements for the matrices if these matrices were not used at
> >>>> all (which happens for the majority of encoders). This is no longer true
> >>>> with this patch.
> >>>
> >>> So?
> >>>
> >>
> >> It means there is a scenario where you break something.
> > 
> > There is no way for the caller to know whether, and how much, will lavc
> > read from those tables, so it's invalid API use.
> > 
> 
> Incorrect: Given that these fields do not a length field, it is legal to
> put pointers to matrices of arbitrary length in the relevant
> AVCodecContext field.

No. Users are not allowed to write random values to random places.
The only meaningful way to use these arrays is with 64 elements,
therefore any caller using a different number is broken.

-- 
Anton Khirnov


More information about the ffmpeg-devel mailing list