Commit 7ab690bf authored by Michael Niedermayer's avatar Michael Niedermayer

indeo4: more complete check for the scan vs block sizes.

Fixes out of array reads

Found-by: Mateusz "j00ru" Jurczyk and Gynvael Coldwind
Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 7581ad24
...@@ -365,6 +365,7 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band, ...@@ -365,6 +365,7 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
band->scan = scan_index_to_tab[scan_indx]; band->scan = scan_index_to_tab[scan_indx];
band->scan_size = band->blk_size;
quant_mat = get_bits(&ctx->gb, 5); quant_mat = get_bits(&ctx->gb, 5);
if (quant_mat == 31) { if (quant_mat == 31) {
...@@ -382,6 +383,11 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band, ...@@ -382,6 +383,11 @@ static int decode_band_hdr(IVI45DecContext *ctx, IVIBandDesc *band,
band->quant_mat = 0; band->quant_mat = 0;
return AVERROR_INVALIDDATA; return AVERROR_INVALIDDATA;
} }
if (band->scan_size != band->blk_size) {
av_log(avctx, AV_LOG_ERROR, "mismatching scan table!\n");
return AVERROR_INVALIDDATA;
}
/* decode block huffman codebook */ /* decode block huffman codebook */
if (ff_ivi_dec_huff_desc(&ctx->gb, get_bits1(&ctx->gb), IVI_BLK_HUFF, if (ff_ivi_dec_huff_desc(&ctx->gb, get_bits1(&ctx->gb), IVI_BLK_HUFF,
&band->blk_vlc, avctx)) &band->blk_vlc, avctx))
......
...@@ -152,6 +152,7 @@ typedef struct IVIBandDesc { ...@@ -152,6 +152,7 @@ typedef struct IVIBandDesc {
int quant_mat; ///< dequant matrix index int quant_mat; ///< dequant matrix index
int glob_quant; ///< quant base for this band int glob_quant; ///< quant base for this band
const uint8_t *scan; ///< ptr to the scan pattern const uint8_t *scan; ///< ptr to the scan pattern
int scan_size; ///< size of the scantable
IVIHuffTab blk_vlc; ///< vlc table for decoding block data IVIHuffTab blk_vlc; ///< vlc table for decoding block data
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment