diff mbox series

[FFmpeg-devel,8/8] avfilter/vf_scale: Cleanup some checks

Message ID 20240708222410.773456-8-michael@niedermayer.cc
State New
Headers show
Series [FFmpeg-devel,1/8] avfilter/vf_elbg: Use unsigned for shifting into the top bit | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 fail Make fate failed
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Michael Niedermayer July 8, 2024, 10:24 p.m. UTC
Fixes: CID1513722 Operands don't affect result

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
---
 libavfilter/vf_scale.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

Comments

Anton Khirnov July 9, 2024, 6:59 a.m. UTC | #1
Quoting Michael Niedermayer (2024-07-09 00:24:10)
> Fixes: CID1513722 Operands don't affect result
> 
> Sponsored-by: Sovereign Tech Fund
> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
> ---
>  libavfilter/vf_scale.c | 6 ++----
>  1 file changed, 2 insertions(+), 4 deletions(-)
> 
> diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
> index bf09196e10d..120ff473f2e 100644
> --- a/libavfilter/vf_scale.c
> +++ b/libavfilter/vf_scale.c
> @@ -645,10 +645,8 @@ static int config_props(AVFilterLink *outlink)
>      if (ret < 0)
>          goto fail;
>  
> -    if (outlink->w > INT_MAX ||
> -        outlink->h > INT_MAX ||
> -        (outlink->h * inlink->w) > INT_MAX ||
> -        (outlink->w * inlink->h) > INT_MAX)
> +    if ((outlink->h * (int64_t)inlink->w) > INT_MAX ||
> +        (outlink->w * (int64_t)inlink->h) > INT_MAX)

assumes int is smaller than 64bit
diff mbox series

Patch

diff --git a/libavfilter/vf_scale.c b/libavfilter/vf_scale.c
index bf09196e10d..120ff473f2e 100644
--- a/libavfilter/vf_scale.c
+++ b/libavfilter/vf_scale.c
@@ -645,10 +645,8 @@  static int config_props(AVFilterLink *outlink)
     if (ret < 0)
         goto fail;
 
-    if (outlink->w > INT_MAX ||
-        outlink->h > INT_MAX ||
-        (outlink->h * inlink->w) > INT_MAX ||
-        (outlink->w * inlink->h) > INT_MAX)
+    if ((outlink->h * (int64_t)inlink->w) > INT_MAX ||
+        (outlink->w * (int64_t)inlink->h) > INT_MAX)
         av_log(ctx, AV_LOG_ERROR, "Rescaled value for width or height is too big.\n");
 
     /* TODO: make algorithm configurable */