[FFmpeg-cvslog] avcodec/jpeg2000dec: Check that atom header is within bytsetream

Michael Niedermayer git at videolan.org
Mon Sep 6 00:20:53 EEST 2021


ffmpeg | branch: master | Michael Niedermayer <michael at niedermayer.cc> | Sun Sep  5 21:00:38 2021 +0200| [3c659f861856d751fe3aa1358b1cccff3117f948] | committer: Michael Niedermayer

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

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

 libavcodec/jpeg2000dec.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index e62f7b19e6..c95f22bc90 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/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;



More information about the ffmpeg-cvslog mailing list