aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2021-09-05 21:00:38 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2021-09-08 21:31:50 +0200
commitb3e21be8e18b0304473a7b507a4545336cc658c4 (patch)
tree0922a0e420e7b17a497389053530337b87388017
parent7d58def70a530d0693bc0a9762db7c544553b256 (diff)
downloadffmpeg-b3e21be8e18b0304473a7b507a4545336cc658c4.tar.gz
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> (cherry picked from commit 3c659f861856d751fe3aa1358b1cccff3117f948) Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/jpeg2000dec.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 63edbcda09..0d7ade5ce8 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2361,6 +2361,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;