1
From d71f5b5b2b9f2e0ba2da67ca2c15b9bbb69ac1fc Mon Sep 17 00:00:00 2001
2
From: michael <michael@9553f0bf-9b14-0410-a0b8-cfaf0461ba5b>
3
Date: Wed, 23 Sep 2009 13:08:48 +0000
4
Subject: [PATCH 09/12] Check begin/end/partition_size.
5
23_vorbis_sane_partition.patch by chrome.
6
Also this should be better documented but i prefer not to leave potential
7
security issues open due to missing documentation.
9
git-svn-id: file:///var/local/repositories/ffmpeg/trunk@19996 9553f0bf-9b14-0410-a0b8-cfaf0461ba5b
11
libavcodec/vorbis_dec.c | 9 +++++++++
12
1 files changed, 9 insertions(+), 0 deletions(-)
14
diff --git a/libavcodec/vorbis_dec.c b/libavcodec/vorbis_dec.c
15
index ca43e99..ec3c561 100644
16
--- a/libavcodec/vorbis_dec.c
17
+++ b/libavcodec/vorbis_dec.c
21
#define V_MAX_VLCS (1<<16)
22
+#define V_MAX_PARTITIONS (1<<20)
26
@@ -638,6 +639,14 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc){
27
res_setup->begin=get_bits(gb, 24);
28
res_setup->end=get_bits(gb, 24);
29
res_setup->partition_size=get_bits(gb, 24)+1;
30
+ /* Validations to prevent a buffer overflow later. */
31
+ if (res_setup->begin>res_setup->end
32
+ || res_setup->end>vc->blocksize[1]/(res_setup->type==2?1:2)
33
+ || (res_setup->end-res_setup->begin)/res_setup->partition_size>V_MAX_PARTITIONS) {
34
+ 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);
38
res_setup->classifications=get_bits(gb, 6)+1;
39
res_setup->classbook=get_bits(gb, 8);
40
if (res_setup->classbook>=vc->codebook_count) {