Projects
Essentials
A_tw-ffmpeg-4
ffmpeg-4-CVE-2026-38350-part01-aca41d3.patch
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File ffmpeg-4-CVE-2026-38350-part01-aca41d3.patch of Package A_tw-ffmpeg-4
From: Michael Niedermayer <michael@niedermayer.cc> Date: Tue, 29 Jul 2025 18:57:53 +0000 Subject: [PATCH 2/3] swscale/output: Fix all bilinear integer overflows Upstream: aca41d3d9327be4d6ab036f494b700118fcc04e1 References: bsc#1277370 CVE-2026-38350 Target: FFmpeg n4.4.8; apply in series order Backport notes: - Preserve SwsContext, existing signatures and endian handling. - Port all changes in the three _2_c_template calculation bodies. - The two _1_c_template paths use fixed chroma averaging and have no uvalpha1 variable; their upstream hunks are not applicable. Ticket11686 hinted at one of these overflows this fixes them all Issue in line 1325/1326 found by HAORAN FANG <xfanghaoran@gmail.com> Signed-off-by: Michael Niedermayer <michael@niedermayer.cc> --- diff --git a/libswscale/output.c b/libswscale/output.c --- a/libswscale/output.c +++ b/libswscale/output.c @@ -938,26 +938,27 @@ yuv2ya16_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *unused_ubuf[2], const int32_t *unused_vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, - int yalpha, int unused_uvalpha, int y, + int yalpha_param, int unused_uvalpha, int y, enum AVPixelFormat target, int unused_hasAlpha, int unused_eightbytes) { + unsigned yalpha = yalpha_param; int hasAlpha = abuf && abuf[0] && abuf[1]; const int32_t *buf0 = buf[0], *buf1 = buf[1], *abuf0 = hasAlpha ? abuf[0] : NULL, *abuf1 = hasAlpha ? abuf[1] : NULL; - int yalpha1 = 4096 - yalpha; + unsigned yalpha1 = 4096 - yalpha; int i; av_assert2(yalpha <= 4096U); for (i = 0; i < dstW; i++) { - int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 15; + int Y = (int)(buf0[i] * yalpha1 + buf1[i] * yalpha) >> 15; int A; Y = av_clip_uint16(Y); if (hasAlpha) { - A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 15; + A = (int)(abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 15; A = av_clip_uint16(A); } @@ -1078,16 +1079,18 @@ yuv2rgba64_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, - int yalpha, int uvalpha, int y, + int yalpha_param, int uvalpha_param, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) { + unsigned yalpha = yalpha_param; + unsigned uvalpha = uvalpha_param; const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], *abuf0 = hasAlpha ? abuf[0] : NULL, *abuf1 = hasAlpha ? abuf[1] : NULL; - int yalpha1 = 4096 - yalpha; - int uvalpha1 = 4096 - uvalpha; + unsigned yalpha1 = 4096 - yalpha; + unsigned uvalpha1 = 4096 - uvalpha; int i; int A1 = 0xffff<<14, A2 = 0xffff<<14; @@ -1095,10 +1098,10 @@ av_assert2(uvalpha <= 4096U); for (i = 0; i < ((dstW + 1) >> 1); i++) { - unsigned Y1 = (buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14; - unsigned Y2 = (buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14; - int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14; - int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14; + unsigned Y1 = (int)(buf0[i * 2] * yalpha1 + buf1[i * 2] * yalpha) >> 14; + unsigned Y2 = (int)(buf0[i * 2 + 1] * yalpha1 + buf1[i * 2 + 1] * yalpha) >> 14; + int U = (int)(ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14; + int V = (int)(vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14; int R, G, B; Y1 -= c->yuv2rgb_y_offset; @@ -1113,8 +1116,8 @@ B = U * c->yuv2rgb_u2b_coeff; if (hasAlpha) { - A1 = (abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 1; - A2 = (abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 1; + A1 = (int)(abuf0[i * 2 ] * yalpha1 + abuf1[i * 2 ] * yalpha) >> 1; + A2 = (int)(abuf0[i * 2 + 1] * yalpha1 + abuf1[i * 2 + 1] * yalpha) >> 1; A1 += 1 << 13; A2 += 1 << 13; @@ -1310,16 +1313,18 @@ yuv2rgba64_full_2_c_template(SwsContext *c, const int32_t *buf[2], const int32_t *ubuf[2], const int32_t *vbuf[2], const int32_t *abuf[2], uint16_t *dest, int dstW, - int yalpha, int uvalpha, int y, + int yalpha_param, int uvalpha_param, int y, enum AVPixelFormat target, int hasAlpha, int eightbytes) { + unsigned yalpha = yalpha_param; + unsigned uvalpha = uvalpha_param; const int32_t *buf0 = buf[0], *buf1 = buf[1], *ubuf0 = ubuf[0], *ubuf1 = ubuf[1], *vbuf0 = vbuf[0], *vbuf1 = vbuf[1], *abuf0 = hasAlpha ? abuf[0] : NULL, *abuf1 = hasAlpha ? abuf[1] : NULL; - int yalpha1 = 4096 - yalpha; - int uvalpha1 = 4096 - uvalpha; + unsigned yalpha1 = 4096 - yalpha; + unsigned uvalpha1 = 4096 - uvalpha; int i; int A = 0xffff<<14; @@ -1327,9 +1332,9 @@ av_assert2(uvalpha <= 4096U); for (i = 0; i < dstW; i++) { - int Y = (buf0[i] * yalpha1 + buf1[i] * yalpha) >> 14; - int U = (ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14; - int V = (vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14; + int Y = (int)(buf0[i] * yalpha1 + buf1[i] * yalpha) >> 14; + int U = (int)(ubuf0[i] * uvalpha1 + ubuf1[i] * uvalpha - (128 << 23)) >> 14; + int V = (int)(vbuf0[i] * uvalpha1 + vbuf1[i] * uvalpha - (128 << 23)) >> 14; int R, G, B; Y -= c->yuv2rgb_y_offset; @@ -1341,7 +1346,7 @@ B = U * c->yuv2rgb_u2b_coeff; if (hasAlpha) { - A = (abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 1; + A = (int)(abuf0[i] * yalpha1 + abuf1[i] * yalpha) >> 1; A += 1 << 13; }
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.