aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Niedermayer <michael@niedermayer.cc>2020-08-02 01:15:34 +0200
committerMichael Niedermayer <michael@niedermayer.cc>2020-08-10 14:54:32 +0200
commita5ac81952e8ea3b071190d36a41b7bab4e957f66 (patch)
treeab8568858320e90d8038d3ea4593a762730a62b9
parentde5cb6c060236c4667eac1006dfd1e54f06bde9f (diff)
downloadffmpeg-a5ac81952e8ea3b071190d36a41b7bab4e957f66.tar.gz
avcodec/jpeg2000dec: Check remaining data in packed_headers_stream before use
Fixes: out of array read Fixes: 24487/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5165847820369920 Fixes: 24636/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5700973918683136 Fixes: 24683/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-6202883897556992 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
-rw-r--r--libavcodec/jpeg2000dec.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index a4c20f45c5..624542c2f8 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);
}