diff options
author | Reinhard Tartler <siretart@tauware.de> | 2012-01-05 21:40:18 +0100 |
---|---|---|
committer | Reinhard Tartler <siretart@tauware.de> | 2012-01-07 23:16:52 +0100 |
commit | e6d527ff729e42d80e4756cab779ff4ad693631b (patch) | |
tree | 40ba1836c8a1cf1ccb4432a5a7555f2bc12e4921 /libavcodec/vorbisdec.c | |
parent | badb195d139f15dc189dd3f78930c9cbfce89c24 (diff) | |
download | ffmpeg-e6d527ff729e42d80e4756cab779ff4ad693631b.tar.gz |
vorbisdec: Fix decoding bug with channel handling
Fixes Bug: #191
Chromium Bug: #101458
CVE-2011-3895
Signed-off-by: Reinhard Tartler <siretart@tauware.de>
Diffstat (limited to 'libavcodec/vorbisdec.c')
-rw-r--r-- | libavcodec/vorbisdec.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index e0c38c2360..dd30c0fe7a 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -675,7 +675,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc) res_setup->partition_size = get_bits(gb, 24) + 1; /* Validations to prevent a buffer overflow later. */ if (res_setup->begin>res_setup->end || - res_setup->end > vc->avccontext->channels * vc->blocksize[1] / 2 || + res_setup->end > (res_setup->type == 2 ? vc->avccontext->channels : 1) * vc->blocksize[1] / 2 || (res_setup->end-res_setup->begin) / res_setup->partition_size > V_MAX_PARTITIONS) { av_log(vc->avccontext, AV_LOG_ERROR, "partition out of bounds: type, begin, end, size, blocksize: %"PRIu16", %"PRIu32", %"PRIu32", %u, %"PRIu32"\n", @@ -1478,6 +1478,7 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) uint8_t res_chan[255]; unsigned res_num = 0; int retlen = 0; + int ch_left = vc->audio_channels; if (get_bits1(gb)) { av_log(vc->avccontext, AV_LOG_ERROR, "Not a Vorbis I audio packet.\n"); @@ -1552,9 +1553,14 @@ static int vorbis_parse_audio_packet(vorbis_context *vc) } } residue = &vc->residues[mapping->submap_residue[i]]; + if (ch_left < ch) { + av_log(vc->avccontext, AV_LOG_ERROR, "Too many channels in vorbis_floor_decode.\n"); + return -1; + } vorbis_residue_decode(vc, residue, ch, do_not_decode, ch_res_ptr, blocksize/2); ch_res_ptr += ch * blocksize / 2; + ch_left -= ch; } // Inverse coupling |