Commit cdd0364b80 for ffmpeg
commit cdd0364b807ff9e069733e25e974d2ab88958b83
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sat Nov 14 01:57:51 2026 +0100
avfilter/vf_lut2: mask the index into the lookup table
Fixes: out of array read
Fixes: 7lsmzPaM2P1v
Found during triage of the security report AISLE-2026-R0057
Out of array read Replicated through UnModified FFmpeg with ASAN
diff --git a/libavfilter/vf_lut2.c b/libavfilter/vf_lut2.c
index dfc30754d0..e89ad032ad 100644
--- a/libavfilter/vf_lut2.c
+++ b/libavfilter/vf_lut2.c
@@ -258,6 +258,7 @@ static int lut2_##zname##_##xname##_##yname(AVFilterContext *ctx,
AVFrame *srcx = td->srcx; \
AVFrame *srcy = td->srcy; \
const int odepth = s->odepth; \
+ const int lut_mask = sizeof(xtype) + sizeof(ytype) == 2 ? -1 : (1 << s->depth) - 1; \
int p, y, x; \
\
for (p = 0; p < s->nb_planes; p++) { \
@@ -274,7 +275,7 @@ static int lut2_##zname##_##xname##_##yname(AVFilterContext *ctx,
\
for (y = slice_start; y < slice_end; y++) { \
for (x = 0; x < s->widthx[p]; x++) { \
- dst[x] = av_clip_uintp2_c(lut[(srcyy[x] << s->depthx) | srcxx[x]], odepth); \
+ dst[x] = av_clip_uintp2_c(lut[((srcyy[x] << s->depthx) | srcxx[x]) & lut_mask], odepth); \
} \
\
dst += out->linesize[p] / zdiv; \