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@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
pull/310/head
Michael Niedermayer 6 years ago
parent ee16d14b0a
commit 8e3b01e20e
  1. 3
      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)

Loading…
Cancel
Save