]> git.sesse.net Git - ffmpeg/commitdiff
avcodec/cinepak: Check available input against encoded buffer size
authorMichael Niedermayer <michael@niedermayer.cc>
Sun, 12 May 2019 20:06:30 +0000 (22:06 +0200)
committerMichael Niedermayer <michael@niedermayer.cc>
Tue, 14 May 2019 10:06:26 +0000 (12:06 +0200)
Fixes: Timeout (12sec -> 2sec)
Fixes: 14606/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CINEPAK_fuzzer-5738687561728000
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Reviewed-by: Tomas Härdin <tjoppen@acc.umu.se>
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
libavcodec/cinepak.c

index a5132ddbc075b2b24e6ac0acc036702f5f95d0ec..aeb15de0ed90b17bf811db591a91e6ce8f20d16a 100644 (file)
@@ -323,6 +323,9 @@ static int cinepak_predecode_check (CinepakContext *s)
     num_strips  = AV_RB16 (&s->data[8]);
     encoded_buf_size = AV_RB24(&s->data[1]);
 
+    if (s->size < encoded_buf_size * (int64_t)(100 - s->avctx->discard_damaged_percentage) / 100)
+        return AVERROR_INVALIDDATA;
+
     /* if this is the first frame, check for deviant Sega FILM data */
     if (s->sega_film_skip_bytes == -1) {
         if (!encoded_buf_size) {