From bf9c86f62a24a535030d899e7cdba2b3946f9a5f Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Fri, 5 Jun 2020 22:05:27 +0200 Subject: [PATCH] avcodec/huffyuvdec: Test vertical coordinate more often Fixes: out of array access Fixes: 22892/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_HYMT_fuzzer-5135996772679680.fuzz Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer (cherry picked from commit a1223ddc5692772198a02600ecff2545f32b37be) Signed-off-by: Michael Niedermayer --- libavcodec/huffyuvdec.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libavcodec/huffyuvdec.c b/libavcodec/huffyuvdec.c index 5846311bd3..cc286bf444 100644 --- a/libavcodec/huffyuvdec.c +++ b/libavcodec/huffyuvdec.c @@ -984,12 +984,16 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, left= left_prediction(s, p->data[plane], s->temp[0], w, 0); y = 1; + if (y >= h) + break; /* second line is left predicted for interlaced case */ if (s->interlaced) { decode_plane_bitstream(s, w, plane); left = left_prediction(s, p->data[plane] + p->linesize[plane], s->temp[0], w, left); y++; + if (y >= h) + break; } lefttop = p->data[plane][0]; @@ -1101,6 +1105,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } cy = y = 1; + if (y >= height) + break; /* second line is left predicted for interlaced case */ if (s->interlaced) { @@ -1113,6 +1119,8 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, } y++; cy++; + if (y >= height) + break; } /* next 4 pixels are left predicted too */