Commit f157611470 for ffmpeg
commit f157611470599783e3fcfe969407ea1912d1801b
Author: Michael Niedermayer <michael@niedermayer.cc>
Date: Sun Nov 8 01:47:35 2026 +0100
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
diff --git a/libavcodec/rawdec.c b/libavcodec/rawdec.c
index 69df3efcaa..c9d708be84 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;
}