X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fcinepak.c;h=9c5b254231b30cbd79208038b08ff49c14df4f95;hb=1ab3ae6fd5b1866aa42cfc0c5d79700adb7281d8;hp=9b0077402f063794f6cfdda70b6b59442fa43e4f;hpb=14fe81b3a88dfe4dbac12e8715f9a3f05b5ef1bf;p=ffmpeg diff --git a/libavcodec/cinepak.c b/libavcodec/cinepak.c index 9b0077402f0..9c5b254231b 100644 --- a/libavcodec/cinepak.c +++ b/libavcodec/cinepak.c @@ -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) { @@ -353,6 +356,13 @@ static int cinepak_predecode_check (CinepakContext *s) if (s->size < 10 + s->sega_film_skip_bytes + num_strips * 12) return AVERROR_INVALIDDATA; + if (num_strips) { + const uint8_t *data = s->data + 10 + s->sega_film_skip_bytes; + int strip_size = AV_RB24 (data + 1); + if (strip_size < 12 || strip_size > encoded_buf_size) + return AVERROR_INVALIDDATA; + } + return 0; } @@ -463,7 +473,7 @@ static int cinepak_decode_frame(AVCodecContext *avctx, return ret; } - if ((ret = ff_reget_buffer(avctx, s->frame)) < 0) + if ((ret = ff_reget_buffer(avctx, s->frame, 0)) < 0) return ret; if (s->palette_video) {