avcodec/rv40: Test remaining space in loop of get_dimension()
authorMichael Niedermayer <michael@niedermayer.cc>
Tue, 15 Nov 2016 21:50:35 +0000 (22:50 +0100)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 15 Nov 2016 22:08:43 +0000 (23:08 +0100)
Fixes infinite loop
Fixes: 178/fuzz-3-ffmpeg_VIDEO_AV_CODEC_ID_RV40_fuzzer

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

index 465011a..e5ba215 100644 (file)
@@ -109,6 +109,8 @@ static int get_dimension(GetBitContext *gb, const int *dim)
         val = dim[get_bits1(gb) - val];
     if(!val){
         do{
+            if (get_bits_left(gb) < 8)
+                return AVERROR_INVALIDDATA;
             t = get_bits(gb, 8);
             val += t << 2;
         }while(t == 0xFF);