X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fffv1dec.c;h=d3927a25b74951d132b30b9c96aa86efbfd17d26;hb=7174df44fe7b27c85637438ee0052d9d9ff8f382;hp=fda3f09a4feef3822998f47477abf1f769bd7e58;hpb=9aff7d41f65a22a281def975ce2f1979e32a4199;p=ffmpeg diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index fda3f09a4fe..d3927a25b74 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -441,7 +441,7 @@ static int decode_slice(AVCodecContext *c, void *arg) decode_plane(fs, p->data[2] + ps*cx+cy*p->linesize[2], chroma_width, chroma_height, p->linesize[2], 1); } if (fs->transparency) - decode_plane(fs, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], 2); + decode_plane(fs, p->data[3] + ps*x + y*p->linesize[3], width, height, p->linesize[3], (f->version >= 4 && !f->chroma_planes) ? 1 : 2); } else { uint8_t *planes[3] = { p->data[0] + ps * x + y * p->linesize[0], p->data[1] + ps * x + y * p->linesize[1], @@ -476,7 +476,7 @@ static int read_quant_table(RangeCoder *c, int16_t *quant_table, int scale) for (v = 0; i < 128; v++) { unsigned len = get_symbol(c, state, 0) + 1; - if (len > 128 - i) + if (len > 128 - i || !len) return AVERROR_INVALIDDATA; while (len--) { @@ -528,6 +528,8 @@ static int read_extra_header(FFV1Context *f) if (f->version > 2) { c->bytestream_end -= 4; f->micro_version = get_symbol(c, state, 0); + if (f->micro_version < 0) + return AVERROR_INVALIDDATA; } f->ac = f->avctx->coder_type = get_symbol(c, state, 0); if (f->ac > 1) { @@ -545,6 +547,12 @@ static int read_extra_header(FFV1Context *f) f->num_h_slices = 1 + get_symbol(c, state, 0); f->num_v_slices = 1 + get_symbol(c, state, 0); + if (f->chroma_h_shift > 4U || f->chroma_v_shift > 4U) { + av_log(f->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n", + f->chroma_h_shift, f->chroma_v_shift); + return AVERROR_INVALIDDATA; + } + if (f->num_h_slices > (unsigned)f->width || !f->num_h_slices || f->num_v_slices > (unsigned)f->height || !f->num_v_slices ) { @@ -650,6 +658,12 @@ static int read_header(FFV1Context *f) } } + if (chroma_h_shift > 4U || chroma_v_shift > 4U) { + av_log(f->avctx, AV_LOG_ERROR, "chroma shift parameters %d %d are invalid\n", + chroma_h_shift, chroma_v_shift); + return AVERROR_INVALIDDATA; + } + f->colorspace = colorspace; f->avctx->bits_per_raw_sample = bits_per_raw_sample; f->chroma_planes = chroma_planes;