[FFmpeg-devel] [PATCH] avcodec/agm: More completely check size before using it

Michael Niedermayer michael at niedermayer.cc
Wed Apr 3 03:44:19 EEST 2019


Fixes: out of array access
Fixes: 13997/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_AGM_fuzzer-5701427252428800

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/agm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libavcodec/agm.c b/libavcodec/agm.c
index b0e8b80f81..2d2092222d 100644
--- a/libavcodec/agm.c
+++ b/libavcodec/agm.c
@@ -562,7 +562,8 @@ static int decode_frame(AVCodecContext *avctx, void *data,
 
     for (int i = 0; i < 3; i++)
         s->size[i] = bytestream2_get_le32(gbyte);
-    if (32LL + s->size[0] + s->size[1] + s->size[2] > avpkt->size)
+    if (s->size[0] < 0 || s->size[1] < 0 || s->size[2] < 0 ||
+        32LL + s->size[0] + s->size[1] + s->size[2] > avpkt->size)
         return AVERROR_INVALIDDATA;
 
     if ((ret = ff_get_buffer(avctx, frame, AV_GET_BUFFER_FLAG_REF)) < 0)
-- 
2.21.0



More information about the ffmpeg-devel mailing list