]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/ffv1dec: Check state transition table
authorMichael Niedermayer <michael@niedermayer.cc>
Thu, 21 Jun 2018 20:10:23 +0000 (22:10 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Mon, 25 Jun 2018 20:58:45 +0000 (22:58 +0200)
Fixes: Timeout
Fixes: 8646/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_FFV1_fuzzer-5649968353247232
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/ffv1dec.c

index 7658a516850d3ffe2a7913e954f65dcf1a06dae7..261e0cf70c239a966206c6bc6b2a2bea48c05631 100644 (file)
@@ -546,8 +546,14 @@ static int read_header(FFV1Context *f)
         f->ac = get_symbol(c, state, 0);
 
         if (f->ac == AC_RANGE_CUSTOM_TAB) {
-            for (i = 1; i < 256; i++)
-                f->state_transition[i] = get_symbol(c, state, 1) + c->one_state[i];
+            for (i = 1; i < 256; i++) {
+                int st = get_symbol(c, state, 1) + c->one_state[i];
+                if (st < 1 || st > 255) {
+                    av_log(f->avctx, AV_LOG_ERROR, "invalid state transition %d\n", st);
+                    return AVERROR_INVALIDDATA;
+                }
+                f->state_transition[i] = st;
+            }
         }
 
         colorspace          = get_symbol(c, state, 0); //YUV cs type