]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/tiff: Check input space in dng_decode_jpeg()
authorMichael Niedermayer <michael@niedermayer.cc>
Fri, 10 Jul 2020 15:14:43 +0000 (17:14 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Fri, 10 Jul 2020 18:27:07 +0000 (20:27 +0200)
Fixes: out of array read
Fixes: 24034/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-5111884337119232
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/tiff.c

index 6a3ec3ef9515545527c425e5c6fcea1355ee6b23..18b327e800f361eec4cd91b42b4ee7904127b119 100644 (file)
@@ -882,6 +882,9 @@ static int dng_decode_jpeg(AVCodecContext *avctx, AVFrame *frame,
     int is_single_comp, is_u16, pixel_size;
     int ret;
 
+    if (tile_byte_count < 0 || tile_byte_count > bytestream2_get_bytes_left(&s->gb))
+        return AVERROR_INVALIDDATA;
+
     /* Prepare a packet and send to the MJPEG decoder */
     av_init_packet(&jpkt);
     jpkt.data = (uint8_t*)s->gb.buffer;