[FFmpeg-devel,2/2] avcodec/dvdsubdec: Sanity check len in decode_rle()

Submitted by Michael Niedermayer on Sept. 13, 2018, 2:24 a.m.

Details

Message ID 20180913022450.19376-2-michael@niedermayer.cc
State New
Headers show

Commit Message

Michael Niedermayer Sept. 13, 2018, 2:24 a.m.
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 | 2 ++
 1 file changed, 2 insertions(+)

Patch hide | download patch | download mbox

diff --git a/libavcodec/dvdsubdec.c b/libavcodec/dvdsubdec.c
index 13d52c8c68..632a53adab 100644
--- a/libavcodec/dvdsubdec.c
+++ b/libavcodec/dvdsubdec.c
@@ -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;