avcodec/xsubdec: Check that RLE coded image and colors fit in the buffer
authorMichael Niedermayer <michael@niedermayer.cc>
Mon, 22 May 2017 22:20:25 +0000 (00:20 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 22 May 2017 22:21:25 +0000 (00:21 +0200)
Fixes: Timeout
Fixes: 1747/clusterfuzz-testcase-minimized-6035451213250560

Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/xsubdec.c

index 2a766b3..93fd0f4 100644 (file)
@@ -91,6 +91,9 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     // we just ignore it
     bytestream_get_le16(&buf);
 
+    if (buf_end - buf < h + 3*4)
+        return AVERROR_INVALIDDATA;
+
     // allocate sub and set values
     sub->rects =  av_mallocz(sizeof(*sub->rects));
     if (!sub->rects)