Commit 867599594f for ffmpeg
commit 867599594faceb4372ce3c96a12d9c11c92f8d16
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sun Nov 8 03:31:27 2026 +0100
avfilter/vf_field: fail if the bottom field does not fit in the subsampled planes
Such a frame has no complete bottom field, fail instead. Also fail if the
field has no row at all.
Fixes: heap-buffer-overflow (read)
Fixes: i9omtrAF7zcc
Fixes: ANT-2026-350FQR5B-256x6.y4m
Found-by: Claude and Ada Logics
Out of array read Replicated through UnModified FFmpeg with ASAN
diff --git a/libavfilter/vf_field.c b/libavfilter/vf_field.c
index 40fcf73bc4..1fd4de71ff 100644
--- a/libavfilter/vf_field.c
+++ b/libavfilter/vf_field.c
@@ -54,12 +54,23 @@ static int config_props_output(AVFilterLink *outlink)
AVFilterContext *ctx = outlink->src;
FieldContext *field = ctx->priv;
AVFilterLink *inlink = ctx->inputs[0];
+ const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(outlink->format);
field->nb_planes = av_pix_fmt_count_planes(outlink->format);
outlink->w = inlink->w;
outlink->h = (inlink->h + (field->type == FIELD_TYPE_TOP)) / 2;
+ if (field->type == FIELD_TYPE_BOTTOM &&
+ AV_CEIL_RSHIFT(outlink->h, desc->log2_chroma_h) > AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h) / 2) {
+ av_log(ctx, AV_LOG_ERROR, "The chroma planes of height %d have no complete bottom field\n", inlink->h);
+ return AVERROR(EINVAL);
+ }
+ if (!outlink->h) {
+ av_log(ctx, AV_LOG_ERROR, "Height %d is too small\n", inlink->h);
+ return AVERROR(EINVAL);
+ }
+
av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d type:%s -> w:%d h:%d\n",
inlink->w, inlink->h, field->type == FIELD_TYPE_BOTTOM ? "bottom" : "top",
outlink->w, outlink->h);