[FFmpeg-devel] [PATCH 2/2] avcodec/jpeg2000dec: Check remaining data in packed_headers_stream before use
Michael Niedermayer
michael at niedermayer.cc
Sun Aug 2 02:23:23 EEST 2020
Fixes: out of array read
Fixes: 24487/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5165847820369920
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
libavcodec/jpeg2000dec.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index 06ad841934..dcebe97272 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -2184,7 +2184,9 @@ static int jpeg2000_read_main_headers(Jpeg2000DecoderContext *s)
}
if (s->has_ppm) {
- uint32_t tp_header_size = bytestream2_get_be32u(&s->packed_headers_stream);
+ uint32_t tp_header_size = bytestream2_get_be32(&s->packed_headers_stream);
+ if (bytestream2_get_bytes_left(&s->packed_headers_stream) < tp_header_size)
+ return AVERROR_INVALIDDATA;
bytestream2_init(&tp->header_tpg, s->packed_headers_stream.buffer, tp_header_size);
bytestream2_skip(&s->packed_headers_stream, tp_header_size);
}
--
2.17.1
More information about the ffmpeg-devel
mailing list