Commit 63a9ce3921 for ffmpeg
commit 63a9ce3921dc4e4cfbe0a5f729825fcaddc2a64e
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Thu Oct 15 04:06:26 2026 +0200
avfilter/vf_pad_vaapi: do the x/y range check and centering in 64bit
Fixes: Ilayk1MzOixN
Fixes: swarm-Signed-integer-overflow-in-pad-x-y-bounds-check-499261
Regression since: 42eb10ecc6
Found-by: zhang xingxing <2388969553@qq.com>
The report suggested, among other options, widening the comparison.
The overflow in the centering was found during review of the fixes for the report.
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
diff --git a/libavfilter/vf_pad_vaapi.c b/libavfilter/vf_pad_vaapi.c
index 5e9dad3065..a6ceae5b75 100644
--- a/libavfilter/vf_pad_vaapi.c
+++ b/libavfilter/vf_pad_vaapi.c
@@ -133,10 +133,10 @@ static int pad_vaapi_config_output(AVFilterLink *outlink)
return ret;
ctx->x = var_values[VAR_X] = res;
- if (ctx->x < 0 || ctx->x + inlink->w > ctx->w)
- ctx->x = var_values[VAR_X] = (ctx->w - inlink->w) / 2;
- if (ctx->y < 0 || ctx->y + inlink->h > ctx->h)
- ctx->y = var_values[VAR_Y] = (ctx->h - inlink->h) / 2;
+ if (ctx->x < 0 || (int64_t)ctx->x + inlink->w > ctx->w)
+ ctx->x = var_values[VAR_X] = ((int64_t)ctx->w - inlink->w) / 2;
+ if (ctx->y < 0 || (int64_t)ctx->y + inlink->h > ctx->h)
+ ctx->y = var_values[VAR_Y] = ((int64_t)ctx->h - inlink->h) / 2;
/* sanity check params */
if (ctx->w < inlink->w || ctx->h < inlink->h) {