]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/tiff: Check the linearization table size
authorMichael Niedermayer <michael@niedermayer.cc>
Wed, 19 Aug 2020 21:21:21 +0000 (23:21 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 26 Aug 2020 18:31:09 +0000 (20:31 +0200)
Fixes: out of array access
Fixes: 24604/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_TIFF_fuzzer-4843529818603520
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 08dbca9d60f2be00472a802af6414b64b4e8a817..8c0b6f085309b57f78b3884860bf3d0ecc50732e 100644 (file)
@@ -1434,7 +1434,9 @@ static int tiff_decode_tag(TiffContext *s, AVFrame *frame)
             s->sub_ifd = ff_tget(&s->gb, TIFF_LONG, s->le); /** Only get the first SubIFD */
         break;
     case DNG_LINEARIZATION_TABLE:
-        for (int i = 0; i < FFMIN(count, 1 << s->bpp); i++)
+        if (count > FF_ARRAY_ELEMS(s->dng_lut))
+            return AVERROR_INVALIDDATA;
+        for (int i = 0; i < count; i++)
             s->dng_lut[i] = ff_tget(&s->gb, type, s->le);
         break;
     case DNG_BLACK_LEVEL: