Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul B Mahol <onemda@gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 1/2] avcodec/hdrdec: Check for end of input in decompress()
Date: Mon, 26 Dec 2022 15:08:38 +0100
Message-ID: <CAPYw7P4md9MXATqMWQp4P6KBrHkJaubwVndL6mdFGZoSURW-Jw@mail.gmail.com> (raw)
In-Reply-To: <20221225220323.20968-1-michael@niedermayer.cc>

On 12/25/22, Michael Niedermayer <michael@niedermayer.cc> wrote:
> Fixes: Timeout
> Fixes:
> 54386/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HDR_fuzzer-5053598268784640
>
> Found-by: continuous fuzzing process
> https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/hdrdec.c | 14 +++++++++++---
>  1 file changed, 11 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/hdrdec.c b/libavcodec/hdrdec.c
> index 21d3e7f693..998227744b 100644
> --- a/libavcodec/hdrdec.c
> +++ b/libavcodec/hdrdec.c
> @@ -58,6 +58,8 @@ static int decompress(uint8_t *scanline, int w,
> GetByteContext *gb, const uint8_
>      int rshift = 0;
>
>      while (w > 0) {
> +        if (bytestream2_get_bytes_left(gb) < 4)
> +            return AVERROR_INVALIDDATA;
>          scanline[0] = bytestream2_get_byte(gb);
>          scanline[1] = bytestream2_get_byte(gb);
>          scanline[2] = bytestream2_get_byte(gb);
> @@ -143,13 +145,17 @@ static int hdr_decode_frame(AVCodecContext *avctx,
> AVFrame *p,
>          int i;
>
>          if (width < MINELEN || width > MAXELEN) {
> -            decompress(scanline, width, &gb, scanline);
> +            ret = decompress(scanline, width, &gb, scanline);
> +            if (ret < 0)
> +                return ret;
>              goto convert;
>          }
>
>          i = bytestream2_peek_byte(&gb);
>          if (i != 2) {
> -            decompress(scanline, width, &gb, scanline);
> +            ret = decompress(scanline, width, &gb, scanline);
> +            if (ret < 0)
> +                return ret;
>              goto convert;
>          }
>          bytestream2_skip(&gb, 1);
> @@ -161,7 +167,9 @@ static int hdr_decode_frame(AVCodecContext *avctx,
> AVFrame *p,
>          if (scanline[1] != 2 || scanline[2] & 128) {
>              scanline[0] = 2;
>              scanline[3] = i;
> -            decompress(scanline + 4, width - 1, &gb, scanline);
> +            ret = decompress(scanline + 4, width - 1, &gb, scanline);
> +            if (ret < 0)
> +                return ret;
>              goto convert;
>          }
>
> --
> 2.17.1
>

LGTM

> _______________________________________________
> 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".
>
_______________________________________________
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".

  parent reply	other threads:[~2022-12-26 14:08 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-25 22:03 Michael Niedermayer
2022-12-25 22:03 ` [FFmpeg-devel] [PATCH 2/2] avformat/mxfdec: Use 64bit in remainder Michael Niedermayer
2022-12-26 10:36   ` Tomas Härdin
2022-12-26 21:42     ` Michael Niedermayer
2022-12-26 14:11   ` James Almer
2022-12-26 21:39     ` Michael Niedermayer
2022-12-26 14:08 ` Paul B Mahol [this message]
2022-12-26 21:50   ` [FFmpeg-devel] [PATCH 1/2] avcodec/hdrdec: Check for end of input in decompress() 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=CAPYw7P4md9MXATqMWQp4P6KBrHkJaubwVndL6mdFGZoSURW-Jw@mail.gmail.com \
    --to=onemda@gmail.com \
    --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