From e302bafe79e0153f4dc7faecec7203836dcd71a7 Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 9 May 2026 00:00:00 +0000 Subject: [PATCH] avcodec/magicyuv: Expand the s->interlaced slice-height sanity check Fixes: poc_magicyuv.avi Fixes: out of array access Found-by: Ori Hollander of the JFrog Vulnerability Research team (cherry picked from commit 5806e8b9f34f1b0663b3017ef9dd1aa5d08116d1) Signed-off-by: Michael Niedermayer --- libavcodec/magicyuv.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/libavcodec/magicyuv.c b/libavcodec/magicyuv.c index bc40032cac..2d5af052db 100644 --- a/libavcodec/magicyuv.c +++ b/libavcodec/magicyuv.c @@ -564,11 +564,11 @@ static int magy_decode_frame(AVCodecContext *avctx, AVFrame *p, return AVERROR_INVALIDDATA; } + if ((s->slice_height >> s->vshift[1]) <= s->interlaced) { + av_log(avctx, AV_LOG_ERROR, "impossible slice height\n"); + return AVERROR_INVALIDDATA; + } if (s->interlaced) { - if ((s->slice_height >> s->vshift[1]) < 2) { - av_log(avctx, AV_LOG_ERROR, "impossible slice height\n"); - return AVERROR_INVALIDDATA; - } if ((avctx->coded_height % s->slice_height) && ((avctx->coded_height % s->slice_height) >> s->vshift[1]) < 2) { av_log(avctx, AV_LOG_ERROR, "impossible height\n"); return AVERROR_INVALIDDATA;