]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/agm: Do not allow MVs out of the picture area as no edge is allocated
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 2 Nov 2019 07:35:39 +0000 (08:35 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 10 Dec 2019 15:09:14 +0000 (16:09 +0100)
Fixes: out of array access
Fixes: 18499/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5749038406434816
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/agm.c

index 89f85f03c6a2d0811b3f62e6cc1481ec6023ac10..628f324913e518017f09ed8ef0430c89bd23e69f 100644 (file)
@@ -460,8 +460,8 @@ static int decode_inter_plane(AGMContext *s, GetBitContext *gb, int size,
                     return ret;
 
                 if (orig_mv_x >= -32) {
-                    if (y * 8 + mv_y < 0 || y * 8 + mv_y >= h ||
-                        x * 8 + mv_x < 0 || x * 8 + mv_x >= w)
+                    if (y * 8 + mv_y < 0 || y * 8 + mv_y + 8 > h ||
+                        x * 8 + mv_x < 0 || x * 8 + mv_x + 8 > w)
                         return AVERROR_INVALIDDATA;
 
                     copy_block8(frame->data[plane] + (s->blocks_h - 1 - y) * 8 * frame->linesize[plane] + x * 8,