[FFmpeg-devel] [PATCH] avcodec/flac_parser: Consider AV_INPUT_BUFFER_PADDING_SIZE

Michael Niedermayer michael at niedermayer.cc
Fri Oct 22 23:42:12 EEST 2021


On Fri, Oct 22, 2021 at 12:00:19AM +0200, Mattias Wadman wrote:
> On Thu, Oct 21, 2021 at 10:35 PM Michael Niedermayer <michael at niedermayer.cc>
> wrote:
> 
> > On Thu, Oct 21, 2021 at 10:17:25PM +0200, Paul B Mahol wrote:
> > > LGTM for now
> >
> > will apply the improved variant below
> >
> > diff --git a/libavcodec/flac_parser.c b/libavcodec/flac_parser.c
> > index 2c550507fc8..3b27b152fc5 100644
> > --- a/libavcodec/flac_parser.c
> > +++ b/libavcodec/flac_parser.c
> > @@ -55,6 +55,7 @@
> >
> >  /** largest possible size of flac header */
> >  #define MAX_FRAME_HEADER_SIZE 16
> > +#define MAX_FRAME_VERIFY_SIZE (MAX_FRAME_HEADER_SIZE + 1)
> >
> >  typedef struct FLACHeaderMarker {
> >      int offset;       /**< byte offset from start of
> > FLACParseContext->buffer */
> > @@ -99,7 +100,7 @@ static int frame_header_is_valid(AVCodecContext *avctx,
> > const uint8_t *buf,
> >      uint8_t subframe_type;
> >
> >      // header plus one byte from first subframe
> > -    init_get_bits(&gb, buf, MAX_FRAME_HEADER_SIZE * 8 + 8);
> > +    init_get_bits(&gb, buf, MAX_FRAME_VERIFY_SIZE * 8);
> >      if (ff_flac_decode_frame_header(avctx, &gb, fi, 127)) {
> >          return 0;
> >      }
> > @@ -196,7 +197,7 @@ static int
> > find_headers_search_validate(FLACParseContext *fpc, int offset)
> >      uint8_t *header_buf;
> >      int size = 0;
> >      header_buf = flac_fifo_read_wrap(fpc, offset,
> > -                                     MAX_FRAME_HEADER_SIZE,
> > +                                     MAX_FRAME_VERIFY_SIZE +
> > AV_INPUT_BUFFER_PADDING_SIZE,
> >                                       &fpc->wrap_buf,
> >                                       &fpc->wrap_buf_allocated_size);
> >      if (frame_header_is_valid(fpc->avctx, header_buf, &fi)) {
> >
> >
> LGTM

will apply


> 
> But i'm not sure about the PARSER_FLAG_COMPLETE_FRAMES case, hard to tell
> if those code paths will always have
> MAX_FRAME_VERIFY_SIZE+AV_INPUT_BUFFER_PADDING_SIZE buf size.

this issue is still open, yes

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

If you think the mosad wants you dead since a long time then you are either
wrong or dead since a long time.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20211022/6e0dd1f3/attachment.sig>


More information about the ffmpeg-devel mailing list