Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Peter Ross <pross@xvid.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 4/4] avcodec/vqcdec: Check for end of input in decode_vectors()
Date: Sat, 19 Nov 2022 10:03:08 +1100
Message-ID: <Y3gPLDMASfkGB2Em@4eb231a0d1b36cedda43a2a005befe4d> (raw)
In-Reply-To: <20221118210918.3169-4-michael@niedermayer.cc>


[-- Attachment #1.1: Type: text/plain, Size: 2337 bytes --]

On Fri, Nov 18, 2022 at 10:09:18PM +0100, Michael Niedermayer wrote:
> Fixes: Timeout
> Fixes: 52695/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_VQC_fuzzer-4882310386548736
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/vqcdec.c | 14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
> 
> diff --git a/libavcodec/vqcdec.c b/libavcodec/vqcdec.c
> index 5d1a03158c..18cd99462e 100644
> --- a/libavcodec/vqcdec.c
> +++ b/libavcodec/vqcdec.c
> @@ -137,7 +137,7 @@ static void seed_codebooks(VqcContext * s, const int * seed)
>      }
>  }
>  
> -static void decode_vectors(VqcContext * s, const uint8_t * buf, int size, int width, int height)
> +static int decode_vectors(VqcContext * s, const uint8_t * buf, int size, int width, int height)
>  {
>      GetBitContext gb;
>      uint8_t * vectors = s->vectors;
> @@ -155,9 +155,11 @@ static void decode_vectors(VqcContext * s, const uint8_t * buf, int size, int wi
>          *dst++ = get_bits(&gb, 8);
>  
>          while (show_bits(&gb, 2) != 2) {
> -
>              if (dst >= vectors_end - 1)
> -                return;
> +                return 0;
> +
> +            if (get_bits_left(&gb) < 4)
> +                return AVERROR_INVALIDDATA;
>  
>              if (!show_bits(&gb, 4)) {
>                  *dst++ = 0;
> @@ -182,6 +184,8 @@ static void decode_vectors(VqcContext * s, const uint8_t * buf, int size, int wi
>          skip_bits(&gb, 2);
>          vectors += 32;
>      }
> +
> +    return 0;
>  }
>  
>  static void load_coeffs(VqcContext * s, const uint8_t * v, int width, int coeff_width)
> @@ -392,7 +396,9 @@ static int vqc_decode_frame(AVCodecContext *avctx, AVFrame * rframe,
>          avpriv_request_sample(avctx, "gamma=0x%x, contrast=0x%x\n", gamma, contrast);
>  
>      seed_codebooks(s, seed);
> -    decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, avctx->height);
> +    ret = decode_vectors(s, buf + 7, avpkt->size - 7, avctx->width, avctx->height);
> +    if (ret < 0)
> +        return ret;
>      decode_frame(s, avctx->width, avctx->height);

please apply

-- Peter
(A907 E02F A6E5 0CD2 34CD 20D2 6760 79C5 AC40 DD6B)

[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]

[-- Attachment #2: Type: text/plain, Size: 251 bytes --]

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  reply	other threads:[~2022-11-18 23:03 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-18 21:09 [FFmpeg-devel] [PATCH 1/4] avcodec/tiff: Ignore tile_count Michael Niedermayer
2022-11-18 21:09 ` [FFmpeg-devel] [PATCH 2/4] avformat/id3v2: Check taglen in read_uslt() Michael Niedermayer
2022-11-28 19:47   ` Michael Niedermayer
2022-11-18 21:09 ` [FFmpeg-devel] [PATCH 3/4] avcodec/mobiclip: Check input size before (re)allocation Michael Niedermayer
2022-11-19  2:34   ` Shiyou Yin
2022-11-28 19:46   ` Michael Niedermayer
2022-11-18 21:09 ` [FFmpeg-devel] [PATCH 4/4] avcodec/vqcdec: Check for end of input in decode_vectors() Michael Niedermayer
2022-11-18 23:03   ` Peter Ross [this message]
2022-11-19 20:04     ` Michael Niedermayer
2022-11-19 12:40 ` [FFmpeg-devel] [PATCH 1/4] avcodec/tiff: Ignore tile_count Anton Khirnov
2022-11-19 19:49   ` Michael Niedermayer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y3gPLDMASfkGB2Em@4eb231a0d1b36cedda43a2a005befe4d \
    --to=pross@xvid.org \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git