aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGoogle Chrome <>2010-02-09 19:54:42 +0000
committerReinhard Tartler <siretart@tauware.de>2010-02-09 19:54:42 +0000
commit4f5ee3f87b143587309471e1c0fa804847939f65 (patch)
treeb1307847214dc7e9ab5c4fcaf65e4407e22d9339
parent736d36b79231d72699dce3449fc9d80c46d2aa19 (diff)
downloadffmpeg-4f5ee3f87b143587309471e1c0fa804847939f65.tar.gz
Check begin/end/partition_size.
23_vorbis_sane_partition.patch by chrome. Also this should be better documented but i prefer not to leave potential security issues open due to missing documentation. r19996 by michael Originally committed as revision 21729 to svn://svn.ffmpeg.org/ffmpeg/branches/0.5
-rw-r--r--libavcodec/vorbis_dec.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c
index e596d48d2c..b70d5a51c4 100644
--- a/libavcodec/vorbis_dec.c
+++ b/libavcodec/vorbis_dec.c
@@ -37,6 +37,7 @@
#define V_NB_BITS 8
#define V_NB_BITS2 11
#define V_MAX_VLCS (1<<16)
+#define V_MAX_PARTITIONS (1<<20)
#ifndef V_DEBUG
#define AV_DEBUG(...)
@@ -643,6 +644,14 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc){
res_setup->begin=get_bits(gb, 24);
res_setup->end=get_bits(gb, 24);
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->blocksize[1]/(res_setup->type==2?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: %d, %d, %d, %d, %d\n", res_setup->type, res_setup->begin, res_setup->end, res_setup->partition_size, vc->blocksize[1]/2);
+ return 1;
+ }
+
res_setup->classifications=get_bits(gb, 6)+1;
res_setup->classbook=get_bits(gb, 8);
if (res_setup->classbook>=vc->codebook_count) {