From 0f36ad514c45b8267b661e745607411d9a5b42cb Mon Sep 17 00:00:00 2001 From: Michael Niedermayer Date: Sat, 22 Sep 2018 18:14:07 +0200 Subject: [PATCH] avcodec/prosumer: Check remaining space in put byte context Fixes: Timeout Fixes: 10053/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_PROSUMER_fuzzer-5636993883570176 Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg Reviewed-by: Paul B Mahol Signed-off-by: Michael Niedermayer --- libavcodec/prosumer.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/prosumer.c b/libavcodec/prosumer.c index 2420dd5f12..6e98677b55 100644 --- a/libavcodec/prosumer.c +++ b/libavcodec/prosumer.c @@ -57,6 +57,8 @@ static int decompress(GetByteContext *gb, int size, PutByteContext *pb, const ui b = lut[2 * idx]; while (1) { + if (bytestream2_get_bytes_left_p(pb) <= 0) + return 0; if (((b & 0xFF00u) != 0x8000u) || (b & 0xFFu)) { if ((b & 0xFF00u) != 0x8000u) { bytestream2_put_le16(pb, b);