diff options
author | Michael Niedermayer <michael@niedermayer.cc> | 2018-04-17 02:13:43 +0200 |
---|---|---|
committer | Michael Niedermayer <michael@niedermayer.cc> | 2018-07-08 19:45:46 +0200 |
commit | 6b382d4d8640fe9f7f96b440ab1408bf22ba7f62 (patch) | |
tree | 7e5cdadd2b83feac29e7d777540a44fb9593e823 /libavcodec/cinepak.c | |
parent | b01b57f7e0428bc0b52828f7cee7cc5f28cf0422 (diff) | |
download | ffmpeg-6b382d4d8640fe9f7f96b440ab1408bf22ba7f62.tar.gz |
avcodec/cinepak: Skip empty frames
Speeds up decoding from 3 to 0.1 seconds for 6302/clusterfuzz-testcase-minimized-ffmpeg_AV_CODEC_ID_CINEPAK_fuzzer-5626371985375232
Fixes: Timeout
Found-by: continuous fuzzing process https://github.com/google/oss-fuzz/tree/master/projects/ffmpeg
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
(cherry picked from commit 9033920bec9ccf17de205fc17c2b330906b200f5)
Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>
Diffstat (limited to 'libavcodec/cinepak.c')
-rw-r--r-- | libavcodec/cinepak.c | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index 778a398c03..82a7631829 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -444,6 +444,7 @@ static int cinepak_decode_frame(AVCodecContext *avctx, const uint8_t *buf = avpkt->data; int ret = 0, buf_size = avpkt->size; CinepakContext *s = avctx->priv_data; + int num_strips; s->data = buf; s->size = buf_size; @@ -451,6 +452,12 @@ static int cinepak_decode_frame(AVCodecContext *avctx, if (s->size < 10) return AVERROR_INVALIDDATA; + num_strips = AV_RB16 (&s->data[8]); + + //Empty frame, do not waste time + if (!num_strips && (!s->palette_video || !av_packet_get_side_data(avpkt, AV_PKT_DATA_PALETTE, NULL))) + return buf_size; + if ((ret = cinepak_predecode_check(s)) < 0) { av_log(avctx, AV_LOG_ERROR, "cinepak_predecode_check failed\n"); return ret; |