summaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-12-07 04:25:17 +0100
committerMichael Niedermayer <michaelni@gmx.at>2012-12-07 13:43:40 +0100
commitea6da80cb41af9e854822d72b5dbe92ea5ca9909 (patch)
tree752ad9628a5a265850a76f0226690fcd800489c5 /libavcodec
parentf5d6b0c9c2bd593c8780ce073fad23cc7a16ef21 (diff)
downloadffmpeg-streaming-ea6da80cb41af9e854822d72b5dbe92ea5ca9909.zip
ffmpeg-streaming-ea6da80cb41af9e854822d72b5dbe92ea5ca9909.tar.gz
diracdec: check dimensions against chroma format.
Fixes out of array reads Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/dirac.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c
index 4fcb3a2..2dd754f 100644
--- a/libavcodec/dirac.c
+++ b/libavcodec/dirac.c
@@ -119,6 +119,7 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
AVRational frame_rate = {0,0};
unsigned luma_depth = 8, luma_offset = 16;
int idx;
+ int chroma_x_shift, chroma_y_shift;
/* [DIRAC_STD] 10.3.2 Frame size. frame_size(video_params) */
/* [DIRAC_STD] custom_dimensions_flag */
@@ -235,6 +236,12 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
av_log(avctx, AV_LOG_WARNING, "Bitdepth greater than 8\n");
avctx->pix_fmt = dirac_pix_fmt[!luma_offset][source->chroma_format];
+ avcodec_get_chroma_sub_sample(avctx->pix_fmt, &chroma_x_shift, &chroma_y_shift);
+ if (!(source->width % (1<<chroma_x_shift)) || !(source->height % (1<<chroma_y_shift))) {
+ av_log(avctx, AV_LOG_ERROR, "Dimensions must be a integer multiply of the chroma subsampling\n");
+ return AVERROR_INVALIDDATA;
+ }
+
/* [DIRAC_STD] 10.3.9 Colour specification. colour_spec(video_params) */
if (get_bits1(gb)) { /* [DIRAC_STD] custom_colour_spec_flag */
OpenPOWER on IntegriCloud