Commit 3ed2e4d624 for ffmpeg
commit 3ed2e4d62492e02ffb7188e13aae5ccbf966851e
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Mon Nov 16 06:56:38 2026 +0100
swscale/output: avoid signed overflow in the chroma products of yuv2gbrp16_full_X_c()
Signed integer overflow Replicated through API with UBSAN
Fixes: signed integer overflow: -130356 * 16525 cannot be represented in type 'int'
Fixes: 574937224/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-5275640446910464
Fixes: RSXytemqmJPo
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
diff --git a/libswscale/output.c b/libswscale/output.c
index 3e9086a310..463de1d9d2 100644
--- a/libswscale/output.c
+++ b/libswscale/output.c
@@ -2522,9 +2522,9 @@ yuv2gbrp16_full_X_c(SwsInternal *c, const int16_t *lumFilter,
Y -= c->yuv2rgb_y_offset;
Y *= c->yuv2rgb_y_coeff;
Y += (1 << 13) - (1 << 29);
- R = V * c->yuv2rgb_v2r_coeff;
- G = V * c->yuv2rgb_v2g_coeff + U * c->yuv2rgb_u2g_coeff;
- B = U * c->yuv2rgb_u2b_coeff;
+ R = V * (unsigned)c->yuv2rgb_v2r_coeff;
+ G = V * (unsigned)c->yuv2rgb_v2g_coeff + U * (unsigned)c->yuv2rgb_u2g_coeff;
+ B = U * (unsigned)c->yuv2rgb_u2b_coeff;
dest16[2][i] = av_clip_uintp2(((Y + (int64_t)R) >> 14) + (1<<15), 16);
dest16[0][i] = av_clip_uintp2(((Y + (int64_t)G) >> 14) + (1<<15), 16);