[FFmpeg-cvslog] avcodec/jpeg2000dec: Check that there are enough bytes for all tiles
Michael Niedermayer
git at videolan.org
Sat Jul 7 19:13:42 EEST 2018
ffmpeg | branch: release/3.4 | Michael Niedermayer <michael at niedermayer.cc> | Mon Jul 2 18:40:08 2018 +0200| [428c3e5975d3cf742b97aeb4a8352ed3bcd8bb0d] | committer: Michael Niedermayer
avcodec/jpeg2000dec: Check that there are enough bytes for all tiles
Fixes: OOM
Fixes: 8781/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_JPEG2000_fuzzer-5810709081358336
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
(cherry picked from commit 0898a3d9909960324e27d3a7a4f48c4effbb654a)
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=428c3e5975d3cf742b97aeb4a8352ed3bcd8bb0d
---
libavcodec/jpeg2000dec.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/libavcodec/jpeg2000dec.c b/libavcodec/jpeg2000dec.c
index d8325320de..0c3ebfcf11 100644
--- a/libavcodec/jpeg2000dec.c
+++ b/libavcodec/jpeg2000dec.c
@@ -342,7 +342,10 @@ static int get_siz(Jpeg2000DecoderContext *s)
s->numXtiles = ff_jpeg2000_ceildiv(s->width - s->tile_offset_x, s->tile_width);
s->numYtiles = ff_jpeg2000_ceildiv(s->height - s->tile_offset_y, s->tile_height);
- if (s->numXtiles * (uint64_t)s->numYtiles > INT_MAX/sizeof(*s->tile)) {
+ // There must be at least a SOT and SOD per tile, their minimum size is 14
+ if (s->numXtiles * (uint64_t)s->numYtiles > INT_MAX/sizeof(*s->tile) ||
+ s->numXtiles * s->numYtiles * 14LL > bytestream2_size(&s->g)
+ ) {
s->numXtiles = s->numYtiles = 0;
return AVERROR(EINVAL);
}
More information about the ffmpeg-cvslog
mailing list