]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/dvdsubdec: Sanity check len in decode_rle()
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 13 Sep 2018 01:33:50 +0000 (03:33 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Wed, 19 Sep 2018 21:16:00 +0000 (23:16 +0200)
Fixes: Timeout
Fixes: 9778/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_DVDSUB_fuzzer-5186007132536832
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/dvdsubdec.c

index 13d52c8c688b9ce9a566c8edf3815fcc8fb07c2f..632a53adabcb86b1841f94d2fecc1b2fb05d6f58 100644 (file)
@@ -125,6 +125,8 @@ static int decode_rle(uint8_t *bitmap, int linesize, int w, int h, uint8_t used_
             len = decode_run_8bit(&gb, &color);
         else
             len = decode_run_2bit(&gb, &color);
+        if (len != INT_MAX && len > w - x)
+            return AVERROR_INVALIDDATA;
         len = FFMIN(len, w - x);
         memset(d + x, color, len);
         used_color[color] = 1;