[FFmpeg-devel] [PATCH 1/4] avcodec/adts_parser: Don't presume buffer to be padded

Andreas Rheinhardt andreas.rheinhardt at outlook.com
Sat May 18 19:59:00 EEST 2024


Andreas Rheinhardt:
> The documentation of av_adts_header_parse() does not require
> the buffer to be padded at all.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at outlook.com>
> ---
>  libavcodec/adts_parser.c | 7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/adts_parser.c b/libavcodec/adts_parser.c
> index 6c22c86ef2..81e2669149 100644
> --- a/libavcodec/adts_parser.c
> +++ b/libavcodec/adts_parser.c
> @@ -28,9 +28,14 @@
>  int av_adts_header_parse(const uint8_t *buf, uint32_t *samples, uint8_t *frames)
>  {
>  #if CONFIG_ADTS_HEADER
> +    uint8_t tmpbuf[AV_AAC_ADTS_HEADER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE];
>      GetBitContext gb;
>      AACADTSHeaderInfo hdr;
> -    int err = init_get_bits8(&gb, buf, AV_AAC_ADTS_HEADER_SIZE);
> +    int err;
> +    if (!buf)
> +        return AVERROR(EINVAL);
> +    memcpy(tmpbuf, buf, AV_AAC_ADTS_HEADER_SIZE);
> +    err = init_get_bits8(&gb, tmpbuf, AV_AAC_ADTS_HEADER_SIZE);
>      if (err < 0)
>          return err;
>      err = ff_adts_header_parse(&gb, &hdr);

Will apply this patchset with the remarks by Andrew and James addressed
tomorrow unless there are objections.

- Andreas



More information about the ffmpeg-devel mailing list