Skip to content

Commit c632716

Browse files
author
Monty
committed
Modify fix for Trac #1572; some files from the earliest beta
accidentally used an oversized phrasebook in res decode; allow these [technically corrept] files to play. The attack fix is still watertight, the check is simply made in a different way. svn path=/trunk/vorbis/; revision=16552
1 parent c5b59af commit c632716

File tree

4 files changed

+14
-9
lines changed

4 files changed

+14
-9
lines changed

lib/backends.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ typedef struct vorbis_info_residue0{
109109
/* first stage (lossless partitioning) */
110110
int grouping; /* group n vectors per partition */
111111
int partitions; /* possible codebooks for a partition */
112+
int partvals; /* partitions ^ groupbook dim */
112113
int groupbook; /* huffbook for partitioning */
113114
int secondstages[64]; /* expanded out to pointers in lookup */
114115
int booklist[512]; /* list of second stage books */

lib/modes/residue_44.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
/***** residue backends *********************************************/
2323

2424
static const vorbis_info_residue0 _residue_44_low={
25-
0,-1, -1, 9,-1,
25+
0,-1, -1, 9,-1,-1,
2626
/* 0 1 2 3 4 5 6 7 */
2727
{0},
2828
{-1},
@@ -31,7 +31,7 @@ static const vorbis_info_residue0 _residue_44_low={
3131
};
3232

3333
static const vorbis_info_residue0 _residue_44_mid={
34-
0,-1, -1, 10,-1,
34+
0,-1, -1, 10,-1,-1,
3535
/* 0 1 2 3 4 5 6 7 8 */
3636
{0},
3737
{-1},
@@ -40,7 +40,7 @@ static const vorbis_info_residue0 _residue_44_mid={
4040
};
4141

4242
static const vorbis_info_residue0 _residue_44_high={
43-
0,-1, -1, 10,-1,
43+
0,-1, -1, 10,-1,-1,
4444
/* 0 1 2 3 4 5 6 7 8 */
4545
{0},
4646
{-1},

lib/modes/residue_44u.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,15 @@
2323

2424

2525
static const vorbis_info_residue0 _residue_44_low_un={
26-
0,-1, -1, 8,-1,
26+
0,-1, -1, 8,-1,-1,
2727
{0},
2828
{-1},
2929
{ .5, 1.5, 1.5, 2.5, 2.5, 4.5, 28.5},
3030
{ -1, 25, -1, 45, -1, -1, -1}
3131
};
3232

3333
static const vorbis_info_residue0 _residue_44_mid_un={
34-
0,-1, -1, 10,-1,
34+
0,-1, -1, 10,-1,-1,
3535
/* 0 1 2 3 4 5 6 7 8 9 */
3636
{0},
3737
{-1},
@@ -40,7 +40,7 @@ static const vorbis_info_residue0 _residue_44_mid_un={
4040
};
4141

4242
static const vorbis_info_residue0 _residue_44_hi_un={
43-
0,-1, -1, 10,-1,
43+
0,-1, -1, 10,-1,-1,
4444
/* 0 1 2 3 4 5 6 7 8 9 */
4545
{0},
4646
{-1},

lib/res0.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,10 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
238238

239239
/* verify the phrasebook is not specifying an impossible or
240240
inconsistent partitioning scheme. */
241+
/* modify the phrasebook ranging check from r16327; an early beta
242+
encoder had a bug where it used an oversized phrasebook by
243+
accident. These files should continue to be playable, but don't
244+
allow an exploit */
241245
{
242246
int entries = ci->book_param[info->groupbook]->entries;
243247
int dim = ci->book_param[info->groupbook]->dim;
@@ -247,7 +251,7 @@ vorbis_info_residue *res0_unpack(vorbis_info *vi,oggpack_buffer *opb){
247251
if(partvals > entries) goto errout;
248252
dim--;
249253
}
250-
if(partvals < entries) goto errout;
254+
info->partvals = partvals;
251255
}
252256

253257
return(info);
@@ -668,7 +672,7 @@ static int _01inverse(vorbis_block *vb,vorbis_look_residue *vl,
668672
for(j=0;j<ch;j++){
669673
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
670674

671-
if(temp==-1)goto eopbreak;
675+
if(temp==-1 || temp>=info->partvals)goto eopbreak;
672676
partword[j][l]=look->decodemap[temp];
673677
if(partword[j][l]==NULL)goto errout;
674678
}
@@ -884,7 +888,7 @@ int res2_inverse(vorbis_block *vb,vorbis_look_residue *vl,
884888
if(s==0){
885889
/* fetch the partition word */
886890
int temp=vorbis_book_decode(look->phrasebook,&vb->opb);
887-
if(temp==-1)goto eopbreak;
891+
if(temp==-1 || temp>info->partvals)goto eopbreak;
888892
partword[l]=look->decodemap[temp];
889893
if(partword[l]==NULL)goto errout;
890894
}

0 commit comments

Comments
 (0)