avcodec/prosumer: Check remaining space in put byte context
authorMichael Niedermayer <michael@niedermayer.cc>
Sat, 22 Sep 2018 16:14:07 +0000 (18:14 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Sun, 23 Sep 2018 22:49:30 +0000 (00:49 +0200)
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 <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/prosumer.c

index 2420dd5..6e98677 100644 (file)
@@ -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);