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 4/4] avcodec/osq: avoid using too large numbers for shifts and integers in update_residue_parameter()
Date: Fri, 15 Sep 2023 15:54:19 +0200
Message-ID: <CAPYw7P6uZ+uUDQcEBy+WL44bi5FMe9KyRox8E9AKf=75bzQp7w@mail.gmail.com> (raw)
In-Reply-To: <20230915131147.5945-4-michael@niedermayer.cc>

On Fri, Sep 15, 2023 at 3:12 PM Michael Niedermayer <michael@niedermayer.cc>
wrote:

> The code should be changed to not use floats in the VLC parameters
> This patch merely fixes undefined behavior
>
> Fixes: 2.96539e+09 is outside the range of representable values of type
> 'int'
> Fixes: Assertion n>=0 && n<=32 failed at libavcodec/get_bits.h:423
> Fixes:
> 62241/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_OSQ_fuzzer-4525761925873664
>


NAK

Breaks decoding.


>
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavcodec/osq.c | 10 +++++++---
>  1 file changed, 7 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/osq.c b/libavcodec/osq.c
> index e2a84657fb4..e7f11691d2e 100644
> --- a/libavcodec/osq.c
> +++ b/libavcodec/osq.c
> @@ -152,11 +152,15 @@ static int update_residue_parameter(OSQChannel *cb)
>
>      sum = cb->sum;
>      x = sum / cb->count;
> -    rice_k = av_ceil_log2(x);
> +    rice_k = ceil(log2(x));
>      if (rice_k >= 30) {
> -        rice_k = floor(sum / 1.4426952 + 0.5);
> -        if (rice_k < 1)
> +        double f = floor(sum / 1.4426952 + 0.5);
> +        if (f <= 1) {
>              rice_k = 1;
> +        } else if (f >= 31) {
> +            rice_k = 31;
> +        } else
> +            rice_k = f;
>      }
>
>      return rice_k;
> --
> 2.17.1
>
> _______________________________________________
> 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".

  reply	other threads:[~2023-09-15 13:54 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-15 13:11 [FFmpeg-devel] [PATCH 1/4] avcodec/evc_ps: Check cpb_cnt_minus1 and propagate error Michael Niedermayer
2023-09-15 13:11 ` [FFmpeg-devel] [PATCH 2/4] avcodec/evc_ps: Check ref_pic_num and sps_max_dec_pic_buffering_minus1 Michael Niedermayer
2023-09-15 13:57   ` James Almer
2023-09-15 15:01     ` Michael Niedermayer
2023-09-15 13:11 ` [FFmpeg-devel] [PATCH 3/4] avutil/tx_template: Fix some signed integer overflows in DECL_FFT5() Michael Niedermayer
2023-10-03 14:30   ` Michael Niedermayer
2023-09-15 13:11 ` [FFmpeg-devel] [PATCH 4/4] avcodec/osq: avoid using too large numbers for shifts and integers in update_residue_parameter() Michael Niedermayer
2023-09-15 13:54   ` Paul B Mahol [this message]
2023-09-15 14:38     ` Michael Niedermayer
2023-09-22 18:48 ` [FFmpeg-devel] [PATCH 1/4] avcodec/evc_ps: Check cpb_cnt_minus1 and propagate error 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='CAPYw7P6uZ+uUDQcEBy+WL44bi5FMe9KyRox8E9AKf=75bzQp7w@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