[FFmpeg-devel] [PATCH 3/5] lavu/common.h: Fix UB in av_clip_uintp2_c()

Michael Niedermayer michael at niedermayer.cc
Fri May 31 03:27:37 EEST 2024


On Thu, May 30, 2024 at 12:14:09AM +0200, Tomas Härdin wrote:
> 

>  common.h |    4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 1fdb9cd4a83522921c2b15a1e76ff2f65ef61f57  0003-lavu-common.h-Fix-UB-in-av_clip_uintp2_c.patch
> From f81730f8facc54ef23df79ac8d33075403b4f76f Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Tomas=20H=C3=A4rdin?= <git at haerdin.se>
> Date: Thu, 16 May 2024 16:37:58 +0200
> Subject: [PATCH 3/5] lavu/common.h: Fix UB in av_clip_uintp2_c()
> 
> Found by value analysis
> ---
>  libavutil/common.h | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/libavutil/common.h b/libavutil/common.h
> index 715f0a594c..8a3c4d2fcf 100644
> --- a/libavutil/common.h
> +++ b/libavutil/common.h
> @@ -278,8 +278,8 @@ static av_always_inline av_const int av_clip_intp2_c(int a, int p)
>   */
>  static av_always_inline av_const unsigned av_clip_uintp2_c(int a, int p)
>  {
> -    if (a & ~((1<<p) - 1)) return (~a) >> 31 & ((1<<p) - 1);
> -    else                   return  a;
> +    if (a & ~((1U<<p) - 1)) return (~a) >> 31 & ((1U<<p) - 1);
> +    else                    return  a;
>  }

LGTM

thx

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

In fact, the RIAA has been known to suggest that students drop out
of college or go to community college in order to be able to afford
settlements. -- The RIAA
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 195 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20240531/7ffcadf2/attachment.sig>


More information about the ffmpeg-devel mailing list