From 2002436b0c914e18eda4f45ef816b14501a1dbae Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Tue, 23 May 2017 00:20:25 +0200 Subject: [PATCH] avcodec/xsubdec: Check that RLE coded image and colors fit in the buffer 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 --- libavcodec/xsubdec.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/xsubdec.c b/libavcodec/xsubdec.c index 2a766b33f7..93fd0f4d50 100644 --- a/libavcodec/xsubdec.c +++ b/libavcodec/xsubdec.c @@ -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)