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

Michael Niedermayer git at videolan.org
Thu Apr 4 12:32:56 EEST 2019


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Wed Apr  3 02:12:28 2019 +0200| [8e3b01e20ebd82528c3302d6756f3c6dffa4bfb2] | committer: Michael Niedermayer

avcodec/agm: More completely check size before using it

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
Reviewed-by: Paul B Mahol <onemda at gmail.com>
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8e3b01e20ebd82528c3302d6756f3c6dffa4bfb2
---

 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)



More information about the ffmpeg-cvslog mailing list