Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Michael Niedermayer <michael@niedermayer.cc>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v1] avcodec/jpeg2000htdec: check if block decoding will exceed internal precision
Date: Sat, 12 Aug 2023 20:39:38 +0200
Message-ID: <20230812183938.GM7802@pb2> (raw)
In-Reply-To: <20230810234856.2636-1-pal@sandflow.com>


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

On Thu, Aug 10, 2023 at 04:48:56PM -0700, pal@sandflow.com wrote:
> From: Pierre-Anthony Lemieux <pal@palemieux.com>
> 
> Intended to replace https://patchwork.ffmpeg.org/project/ffmpeg/patch/20230802000135.26482-3-michael@niedermayer.cc/
> with a more accurate block decoding magnitude bound.
> 
> ---
>  libavcodec/jpeg2000htdec.c | 32 +++++++++++++++++++++++++++++++-
>  1 file changed, 31 insertions(+), 1 deletion(-)
> 
> diff --git a/libavcodec/jpeg2000htdec.c b/libavcodec/jpeg2000htdec.c
> index 2c4cea5dd9..713dba17e3 100644
> --- a/libavcodec/jpeg2000htdec.c
> +++ b/libavcodec/jpeg2000htdec.c
> @@ -572,6 +572,14 @@ static int jpeg2000_decode_ht_cleanup_segment(const Jpeg2000DecoderContext *s,
>  
>      const uint8_t *vlc_buf = Dcup + Pcup;
>  
> +    /*
> +     * Bound on the recision needed to process the codeblock. The number of
> +     * decoded bit planes is equal to at most cblk->zbp + 2 since S_blk = P if
> +     * there are no placeholder passes or HT Sets and P = cblk->zbp. See Rec.
> +     * ITU-T T.814, 7.6.
> +     */
> +    int maxbp = cblk->zbp + 2;
> +
>      /* convert to raster-scan */
>      const uint16_t is_border_x = width % 2;
>      const uint16_t is_border_y = height % 2;
> @@ -590,6 +598,10 @@ static int jpeg2000_decode_ht_cleanup_segment(const Jpeg2000DecoderContext *s,
>          goto free;
>      }
>  
> +    /* do we have enough precision, assuming a 32-bit decoding path */
> +    if (maxbp >= 32)
> +        return AVERROR_INVALIDDATA;

doesnt this need a goto free ?

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

No human being will ever know the Truth, for even if they happen to say it
by chance, they would not even known they had done so. -- Xenophanes

[-- 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:[~2023-08-12 18:39 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-10 23:48 pal
2023-08-12 18:39 ` Michael Niedermayer [this message]
2023-08-12 20:31   ` Pierre-Anthony Lemieux
2023-08-12 20:32     ` Pierre-Anthony Lemieux

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=20230812183938.GM7802@pb2 \
    --to=michael@niedermayer.cc \
    --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