Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Almer <jamrial@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 3/3] avcodec/hevc_ps: Avoid signed overflow before check on QP
Date: Thu, 27 Apr 2023 15:49:54 -0300
Message-ID: <e6c59e3c-7f56-8ed7-c8c1-7b015ec9dd84@gmail.com> (raw)
In-Reply-To: <20230427183840.1015-3-michael@niedermayer.cc>

On 4/27/2023 3:38 PM, Michael Niedermayer wrote:
> Fixes: signed integer overflow: -2147483648 - 5 cannot be represented in type 'int'
> Fixes: 58066/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HEVC_fuzzer-5312995835379712
> 
> Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>   libavcodec/hevc_ps.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
> index 1533e2a817..6b8f432609 100644
> --- a/libavcodec/hevc_ps.c
> +++ b/libavcodec/hevc_ps.c
> @@ -1522,9 +1522,9 @@ static int pps_scc_extension(GetBitContext *gb, AVCodecContext *avctx,
>       pps->pps_curr_pic_ref_enabled_flag = get_bits1(gb);
>       if (pps->residual_adaptive_colour_transform_enabled_flag = get_bits1(gb)) {
>           pps->pps_slice_act_qp_offsets_present_flag = get_bits1(gb);
> -        pps->pps_act_y_qp_offset  = get_se_golomb_long(gb) - 5;
> -        pps->pps_act_cb_qp_offset = get_se_golomb_long(gb) - 5;
> -        pps->pps_act_cr_qp_offset = get_se_golomb_long(gb) - 3;
> +        pps->pps_act_y_qp_offset  = get_se_golomb_long(gb) - 5U;
> +        pps->pps_act_cb_qp_offset = get_se_golomb_long(gb) - 5U;
> +        pps->pps_act_cr_qp_offset = get_se_golomb_long(gb) - 3U;

Spec compliant values for all of these are in the -7..17 and -9..15 
range, so just use get_se_golomb() instead, which i assume is for small 
values, much like get_ue_golomb().

>   
>   #define CHECK_QP_OFFSET(name) (pps->pps_act_ ## name ## _qp_offset <= -12 || \
>                                  pps->pps_act_ ## name ## _qp_offset >= 12)
_______________________________________________
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-04-27 18:50 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-27 18:38 [FFmpeg-devel] [PATCH 1/3] tools/target_dec_fuzzer: Adjust threshold for rka Michael Niedermayer
2023-04-27 18:38 ` [FFmpeg-devel] [PATCH 2/3] avcodec/hevcdec: do not memcpy into itself Michael Niedermayer
2023-09-07 22:07   ` Michael Niedermayer
2023-04-27 18:38 ` [FFmpeg-devel] [PATCH 3/3] avcodec/hevc_ps: Avoid signed overflow before check on QP Michael Niedermayer
2023-04-27 18:49   ` James Almer [this message]
2023-04-30 19:58     ` Michael Niedermayer
2023-04-30 22:33 ` [FFmpeg-devel] [PATCH 1/3] tools/target_dec_fuzzer: Adjust threshold for rka 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=e6c59e3c-7f56-8ed7-c8c1-7b015ec9dd84@gmail.com \
    --to=jamrial@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