PR #26014 opened by michaelni URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26014 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/26014.patch
>From 1b6be55c2e9be7f89e2463e2c70e3bf44bfbe401 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sun, 8 Nov 2026 01:47:35 +0100 Subject: [PATCH 01/10] avcodec/rawdec: apply the odd dimension I420 fix-up only for even dimensions The layout of such frames with odd dimensions is not known, so do not apply the fix-up to them. Fixes: heap-buffer-overflow (read) Fixes: jviPaxUdJzqk Fixes: ANT-2026-8G1XB01D-poc.avi Found-by: Claude and Ada Logics Out of array read Replicated through UnModified FFmpeg with ASAN --- libavcodec/rawdec.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c index 69df3efcaa3..c9d708be848 100644 --- a/libavcodec/rawdec.c +++ b/libavcodec/rawdec.c @@ -428,7 +428,8 @@ static int raw_decode(AVCodecContext *avctx, AVFrame *frame, avctx->codec_tag == MKTAG('Y', 'V', 'U', '9')) FFSWAP(uint8_t *, frame->data[1], frame->data[2]); - if (avctx->codec_tag == AV_RL32("I420") && (avctx->width+1)*(avctx->height+1) * 3/2 == buf_size) { + if (avctx->codec_tag == AV_RL32("I420") && !((avctx->width | avctx->height) & 1) && + (avctx->width+1)*(avctx->height+1) * 3/2 == buf_size) { frame->data[1] = frame->data[1] + (avctx->width+1)*(avctx->height+1) -avctx->width*avctx->height; frame->data[2] = frame->data[2] + ((avctx->width+1)*(avctx->height+1) -avctx->width*avctx->height)*5/4; } -- 2.54.0 >From a73ffa6615bb096522dbc566f216ae94dfbe468a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sun, 8 Nov 2026 03:31:27 +0100 Subject: [PATCH 02/10] 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 --- libavfilter/vf_field.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/libavfilter/vf_field.c b/libavfilter/vf_field.c index 40fcf73bc49..1fd4de71ff7 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); -- 2.54.0 >From 45ef4f9c03f961b02ddaeb80f9bc328c56e2ab52 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sat, 7 Nov 2026 00:11:38 +0100 Subject: [PATCH 03/10] avfilter/vf_separatefields: require an even chroma height With an odd number of rows in a vertically subsampled plane, the bottom field has one row less than the output height requires Fixes: heap-buffer-overflow (read) Fixes: NVD0gxXiKQI9 Found during triage of the security report i9omtrAF7zcc Out of array read Replicated through UnModified FFmpeg with ASAN --- libavfilter/vf_separatefields.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/libavfilter/vf_separatefields.c b/libavfilter/vf_separatefields.c index c0c0640dcc0..4c50f5beebc 100644 --- a/libavfilter/vf_separatefields.c +++ b/libavfilter/vf_separatefields.c @@ -35,6 +35,7 @@ static int config_props_output(AVFilterLink *outlink) AVFilterLink *inlink = ctx->inputs[0]; FilterLink *il = ff_filter_link(inlink); FilterLink *ol = ff_filter_link(outlink); + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format); s->nb_planes = av_pix_fmt_count_planes(inlink->format); @@ -42,6 +43,10 @@ static int config_props_output(AVFilterLink *outlink) av_log(ctx, AV_LOG_ERROR, "height must be even\n"); return AVERROR_INVALIDDATA; } + if (AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h) & 1) { + av_log(ctx, AV_LOG_ERROR, "chroma height must be even\n"); + return AVERROR_INVALIDDATA; + } outlink->time_base.num = inlink->time_base.num; outlink->time_base.den = inlink->time_base.den * 2; -- 2.54.0 >From b3de8ecb2b9496233f08ee35958929c6495eff96 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sat, 7 Nov 2026 00:16:12 +0100 Subject: [PATCH 04/10] avfilter/vf_stereo3d: require an even chroma height for above-below and interleaved rows input With an odd number of rows in a vertically subsampled plane, the second view has one row less than the output height requires Fixes: heap-buffer-overflow (read) Fixes: DVVOyNZC90mi Found during triage of the security report i9omtrAF7zcc Out of array read Replicated through UnModified FFmpeg with ASAN --- libavfilter/vf_stereo3d.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c index 15d6f31c11f..4037f90eaef 100644 --- a/libavfilter/vf_stereo3d.c +++ b/libavfilter/vf_stereo3d.c @@ -396,6 +396,10 @@ static int config_output(AVFilterLink *outlink) av_log(ctx, AV_LOG_ERROR, "height must be even\n"); return AVERROR_INVALIDDATA; } + if (AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h) & 1) { + av_log(ctx, AV_LOG_ERROR, "chroma height must be even\n"); + return AVERROR_INVALIDDATA; + } break; } -- 2.54.0 >From c6f19292b4ebb51f931cc9c8afabc197ada37b0a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sat, 7 Nov 2026 00:17:42 +0100 Subject: [PATCH 05/10] avfilter/vf_stereo3d: read both views from the same row pair for interleaved rows to checkerboard Fixes: heap-buffer-overflow (read) Fixes: gmosBeD5XeCJ Found during triage of the security report i9omtrAF7zcc Out of array read Replicated through UnModified FFmpeg with ASAN --- libavfilter/vf_stereo3d.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libavfilter/vf_stereo3d.c b/libavfilter/vf_stereo3d.c index 4037f90eaef..80dd3d8971f 100644 --- a/libavfilter/vf_stereo3d.c +++ b/libavfilter/vf_stereo3d.c @@ -973,8 +973,9 @@ copy: const int d1 = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL) && (s->in.format & 1) != (s->out.format & 1); const int d2 = (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL) ? !d1 : 0; const int m = 1 + (s->in.format == INTERLEAVE_COLS_LR || s->in.format == INTERLEAVE_COLS_RL); - uint8_t *left = ileft->data[i] + ileft->linesize[i] * y + s->in_off_left[i] + d1 * s->pixstep[i]; - uint8_t *right = iright->data[i] + iright->linesize[i] * y + s->in_off_right[i] + d2 * s->pixstep[i]; + const int in_y = y / s->in.row_step * s->in.row_step; + uint8_t *left = ileft->data[i] + ileft->linesize[i] * in_y + s->in_off_left[i] + d1 * s->pixstep[i]; + uint8_t *right = iright->data[i] + iright->linesize[i] * in_y + s->in_off_right[i] + d2 * s->pixstep[i]; int p, b; if (s->out.format == CHECKERBOARD_RL && s->in.format != INTERLEAVE_COLS_LR && s->in.format != INTERLEAVE_COLS_RL) -- 2.54.0 >From 121d99f5534286319e18d2912200e0745c2ec57c Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sat, 7 Nov 2026 00:23:02 +0100 Subject: [PATCH 06/10] avfilter/vf_drawtext: do not shape the detection bbox text buffer at init Fixes: heap-buffer-overflow (write) Fixes: cstGjMaHQawL Found during triage of the security report jBRKMspuGY2H Out of array write Replicated through API with ASAN --- libavfilter/vf_drawtext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 2ccb03600e9..11c79ef13ec 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1038,7 +1038,7 @@ static av_cold int init(AVFilterContext *ctx) }; #if CONFIG_LIBFRIBIDI - if (s->text_shaping) + if (s->text_shaping && s->text_source != AV_FRAME_DATA_DETECTION_BBOXES) if ((err = shape_text(ctx)) < 0) return err; #endif -- 2.54.0 >From f893d4839b1bc2df17c93a79f487e36f63ea93c9 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sat, 7 Nov 2026 00:40:56 +0100 Subject: [PATCH 07/10] avfilter/vf_drawtext: do not reload the text file with a detection bbox text source The documentation says that textfile is ignored when text_source is set Fixes: heap-buffer-overflow (write) Fixes: cg1JrtNAcnk5 Found during triage of the security report jBRKMspuGY2H Out of array write Replicated through API with ASAN --- libavfilter/vf_drawtext.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 11c79ef13ec..45c5749176a 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1899,7 +1899,8 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) } } - if (s->reload && !(inl->frame_count_out % s->reload)) { + if (s->reload && s->text_source != AV_FRAME_DATA_DETECTION_BBOXES && + !(inl->frame_count_out % s->reload)) { if ((ret = ff_load_textfile(ctx, (const char *)s->textfile, &s->text, NULL)) < 0) { av_frame_free(&frame); return ret; -- 2.54.0 >From bf2fd1b53ac88166bd4a89ca622c7ff01807ff0a Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sun, 8 Nov 2026 01:47:46 +0100 Subject: [PATCH 08/10] avfilter/vf_drawtext: place the detection bbox text above boxes near the top Fixes: signed integer overflow Fixes: kBR11CyKAEHm Fixes: repro_drawtext.c Found-by: Hicham Ouabella <[email protected]> This is not a security issue. Signed integer overflow Replicated through API with UBSAN --- libavfilter/vf_drawtext.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavfilter/vf_drawtext.c b/libavfilter/vf_drawtext.c index 45c5749176a..2e805c2ee84 100644 --- a/libavfilter/vf_drawtext.c +++ b/libavfilter/vf_drawtext.c @@ -1932,7 +1932,7 @@ static int filter_frame(AVFilterLink *inlink, AVFrame *frame) strcat(s->text, bbox->classify_labels[j]); } s->x = bbox->x; - s->y = bbox->y - s->fontsize; + s->y = (int64_t)bbox->y - s->fontsize; } ret = draw_text(ctx, frame); if (ret < 0) { -- 2.54.0 >From 1ca7e93545164f030a4c9650dbc828f012697eb3 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sat, 7 Nov 2026 00:25:48 +0100 Subject: [PATCH 09/10] tools/qt-faststart: reject a moov atom that starts before the end of the ftyp atom Fixes: allocation-size-too-big Fixes: mcdSpfadtpED Fixes: test_neg5.mov Found-by: Hicham Ouabella <[email protected]> This is not a security issue. Negative allocation size Replicated through UnModified qt-faststart with ASAN --- tools/qt-faststart.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/qt-faststart.c b/tools/qt-faststart.c index 46950a5cf44..a270fa78a96 100644 --- a/tools/qt-faststart.c +++ b/tools/qt-faststart.c @@ -571,6 +571,10 @@ int main(int argc, char *argv[]) perror(argv[1]); goto error_out; } + if (last_offset < start_offset) { + fprintf(stderr, "moov atom overlaps the ftyp atom\n"); + goto error_out; + } moov_atom_size = atom_size; moov_atom = malloc(moov_atom_size); if (!moov_atom) { -- 2.54.0 >From 5a66496df8dbec25d80838fa918cf4b10ef7e845 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer <[email protected]> Date: Sat, 7 Nov 2026 00:33:33 +0100 Subject: [PATCH 10/10] avfilter/setpts: avoid undefined behavior with double to int64 cast Fixes: inf is outside the range of representable values of type 'long' Fixes: nw59dSqw4SNa Found-by: Mindaugas Rukas <[email protected]> This is not a security issue. Out of range conversion Replicated through UnModified FFmpeg with UBSAN --- libavfilter/filters.h | 2 +- libavfilter/setpts.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libavfilter/filters.h b/libavfilter/filters.h index 2df05a727ac..4b2a5564c11 100644 --- a/libavfilter/filters.h +++ b/libavfilter/filters.h @@ -493,7 +493,7 @@ static inline const FFFilter *fffilter(const AVFilter *f) #define AVFILTER_DEFINE_CLASS(fname) \ AVFILTER_DEFINE_CLASS_EXT(fname, #fname, fname##_options) -#define D2TS(d) (isnan(d) ? AV_NOPTS_VALUE : (int64_t)(d)) +#define D2TS(d) ((d) >= INT64_MIN && (d) < (double)INT64_MAX ? (int64_t)(d) : AV_NOPTS_VALUE) #define TS2D(ts) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts)) #define TS2T(ts, tb) ((ts) == AV_NOPTS_VALUE ? NAN : (double)(ts) * av_q2d(tb)) diff --git a/libavfilter/setpts.c b/libavfilter/setpts.c index 5648a9ffae0..ed176a25e79 100644 --- a/libavfilter/setpts.c +++ b/libavfilter/setpts.c @@ -161,7 +161,7 @@ static int config_output_video(AVFilterLink *outlink) static inline char *double2int64str(char *buf, double v) { if (isnan(v)) snprintf(buf, BUF_SIZE, "nan"); - else snprintf(buf, BUF_SIZE, "%"PRId64, (int64_t)v); + else snprintf(buf, BUF_SIZE, "%"PRId64, D2TS(v)); return buf; } -- 2.54.0 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
