1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

swscale/output: Avoid undefined overflow in yuv2rgb_write_full()

Fixes: signed integer overflow: -140140 * 16525 cannot be represented in type 'int'
Fixes: 68859/clusterfuzz-testcase-minimized-ffmpeg_SWS_fuzzer-4516387130245120

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit c221c7422f)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
This commit is contained in:
Michael Niedermayer 2024-06-16 01:59:23 +02:00
parent 076ecf6cb1
commit 1e1a0182f7
No known key found for this signature in database
GPG Key ID: B18E8928B3948D64

View File

@ -1893,9 +1893,9 @@ static av_always_inline void yuv2rgb_write_full(SwsContext *c,
Y -= c->yuv2rgb_y_offset;
Y *= c->yuv2rgb_y_coeff;
Y += 1 << 21;
R = (unsigned)Y + V*c->yuv2rgb_v2r_coeff;
G = (unsigned)Y + V*c->yuv2rgb_v2g_coeff + U*c->yuv2rgb_u2g_coeff;
B = (unsigned)Y + U*c->yuv2rgb_u2b_coeff;
R = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2r_coeff;
G = (unsigned)Y + V*(unsigned)c->yuv2rgb_v2g_coeff + U*(unsigned)c->yuv2rgb_u2g_coeff;
B = (unsigned)Y + U*(unsigned)c->yuv2rgb_u2b_coeff;
if ((R | G | B) & 0xC0000000) {
R = av_clip_uintp2(R, 30);
G = av_clip_uintp2(G, 30);