[FFmpeg-devel] [PATCH v1 01/10] return value check for init_get_bits in wmv2dec.c

Hendrik Leppkes h.leppkes at gmail.com
Thu Aug 12 08:53:59 EEST 2021


On Thu, Aug 12, 2021 at 6:48 AM maryam ebrahimzadeh <me22bee at outlook.com> wrote:
>
> As the second argument for init_get_bits can be crafted, a return value check for this function call is necessary  so replace init_get_bits with init_get_bits8.
>
> ---
>  libavcodec/wmv2dec.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/libavcodec/wmv2dec.c b/libavcodec/wmv2dec.c
> index c500e3e779..73da73c02c 100644
> --- a/libavcodec/wmv2dec.c
> +++ b/libavcodec/wmv2dec.c
> @@ -101,12 +101,14 @@ static int decode_ext_header(Wmv2Context *w)
>      GetBitContext gb;
>      int fps;
>      int code;
> +    int ret;
>
>      if (s->avctx->extradata_size < 4)
>          return AVERROR_INVALIDDATA;
>
> -    init_get_bits(&gb, s->avctx->extradata, 32);
> -
> +    ret = init_get_bits8(&gb, s->avctx->extradata, 4);
> +    if (ret < 0)
> +        return ret;

This is a fixed size, the buffer size is checked right above, what
exactly would the error condition be here?

- Hendrik


More information about the ffmpeg-devel mailing list