avcodec/jpeg2000dec: Check that atom header is within bytsetream

Fixes: Infinite loop
Fixes: 36666/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5912760671141888

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/365/head
Michael Niedermayer 3 years ago
parent 33feb527ff
commit 3c659f8618
  1. 2
      libavcodec/jpeg2000dec.c

@ -2360,6 +2360,8 @@ static int jp2_find_codestream(Jpeg2000DecoderContext *s)
atom_size >= 16) {
uint32_t atom2_size, atom2, atom2_end;
do {
if (bytestream2_get_bytes_left(&s->g) < 8)
break;
atom2_size = bytestream2_get_be32u(&s->g);
atom2 = bytestream2_get_be32u(&s->g);
atom2_end = bytestream2_tell(&s->g) + atom2_size - 8;

Loading…
Cancel
Save