diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-08-30 04:51:09 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-08-31 04:31:04 +0200 |
commit | df2fc635439df6d5ab84d50ae96acb0da07f941e (patch) | |
tree | 0b6ded41fb8f0b97dfcf5f41de28a48b2f8a5c04 | |
parent | 890c36d7ff1a12641c9fe5c84db4398dfb493fc5 (diff) | |
download | ffmpeg-df2fc635439df6d5ab84d50ae96acb0da07f941e.tar.gz |
ffv1dec: check that global parameters dont change in version 0/1
Such changes are not allowed nor supported
Fixes Ticket2906
Found-by: ami_stuff
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 547d690d676064069d44703a1917e0dab7e33445)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
-rw-r--r-- | libavcodec/ffv1dec.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/libavcodec/ffv1dec.c b/libavcodec/ffv1dec.c index 69930d8ea8..8f5f5044fa 100644 --- a/libavcodec/ffv1dec.c +++ b/libavcodec/ffv1dec.c @@ -528,6 +528,7 @@ static int read_header(FFV1Context *f) memset(state, 128, sizeof(state)); if (f->version < 2) { + int chroma_planes, chroma_h_shift, chroma_v_shift, transparency; unsigned v= get_symbol(c, state, 0); if (v >= 2) { av_log(f->avctx, AV_LOG_ERROR, "invalid version %d in ver01 header\n", v); @@ -545,10 +546,26 @@ static int read_header(FFV1Context *f) if (f->version > 0) f->avctx->bits_per_raw_sample = get_symbol(c, state, 0); - f->chroma_planes = get_rac(c, state); - f->chroma_h_shift = get_symbol(c, state, 0); - f->chroma_v_shift = get_symbol(c, state, 0); - f->transparency = get_rac(c, state); + chroma_planes = get_rac(c, state); + chroma_h_shift = get_symbol(c, state, 0); + chroma_v_shift = get_symbol(c, state, 0); + transparency = get_rac(c, state); + + if (f->plane_count) { + if ( chroma_planes != f->chroma_planes + || chroma_h_shift!= f->chroma_h_shift + || chroma_v_shift!= f->chroma_v_shift + || transparency != f->transparency) { + av_log(f->avctx, AV_LOG_ERROR, "Invalid change of global parameters\n"); + return AVERROR_INVALIDDATA; + } + } + + f->chroma_planes = chroma_planes; + f->chroma_h_shift = chroma_h_shift; + f->chroma_v_shift = chroma_v_shift; + f->transparency = transparency; + f->plane_count = 2 + f->transparency; } |