diff options
| author | Monty <xiphmont@xiph.org> | 2000-02-05 23:23:58 +0000 |
|---|---|---|
| committer | Monty <xiphmont@xiph.org> | 2000-02-05 23:23:58 +0000 |
| commit | fbac7476bd4a94ea2b8e2e09ea0b4caea608211c (patch) | |
| tree | 97db09d9f4fb7e7feb793385a81ea27f7ceb43e6 /lib | |
| parent | 5ccc61230de45f33b8d976c97fad2c09a2d6b1e7 (diff) | |
| download | libvorbis-git-fbac7476bd4a94ea2b8e2e09ea0b4caea608211c.tar.gz | |
Fix for overflow bug in bitwise routines; read past end triggered too late.
Monty
svn path=/trunk/vorbis/; revision=248
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/bitwise.c | 8 | ||||
| -rw-r--r-- | lib/codebook.c | 6 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/bitwise.c b/lib/bitwise.c index 2f87a0c5..37599b64 100644 --- a/lib/bitwise.c +++ b/lib/bitwise.c @@ -12,7 +12,7 @@ ******************************************************************** function: packing variable sized words into an octet stream - last mod: $Id: bitwise.c,v 1.6 2000/01/12 11:16:35 xiphmont Exp $ + last mod: $Id: bitwise.c,v 1.7 2000/02/05 23:23:56 xiphmont Exp $ ********************************************************************/ @@ -101,7 +101,7 @@ long _oggpack_look(oggpack_buffer *b,int bits){ if(b->endbyte+4>=b->storage){ /* not the main path */ - if(b->endbyte+(bits+b->endbit-1)/8>b->storage)return(-1); + if(b->endbyte+(bits-1)/8>=b->storage)return(-1); } ret=b->ptr[0]>>b->endbit; @@ -149,7 +149,7 @@ long _oggpack_read(oggpack_buffer *b,int bits){ if(b->endbyte+4>=b->storage){ /* not the main path */ ret=-1; - if(b->endbyte+(bits+b->endbit-1)/8>b->storage)goto overflow; + if(b->endbyte+(bits-1)/8>=b->storage)goto overflow; } ret=b->ptr[0]>>b->endbit; @@ -363,7 +363,7 @@ int main(void){ fprintf(stderr,"\nSingle bit unclicpped packing: "); cliptest(testbuffer3,test3size,1,six,sixsize); - fprintf(stderr,"ok.\n"); + fprintf(stderr,"ok.\n\n"); return(0); } #endif diff --git a/lib/codebook.c b/lib/codebook.c index a51cf4fe..a7a6a53d 100644 --- a/lib/codebook.c +++ b/lib/codebook.c @@ -12,7 +12,7 @@ ******************************************************************** function: basic codebook pack/unpack/code/decode operations - last mod: $Id: codebook.c,v 1.4 2000/01/28 09:05:08 xiphmont Exp $ + last mod: $Id: codebook.c,v 1.5 2000/02/05 23:23:58 xiphmont Exp $ ********************************************************************/ @@ -553,7 +553,7 @@ int main(){ _oggpack_reset(&write); vorbis_book_init_encode(&c,testlist[ptr]); /* get it into memory we can write */ - vorbis_book_pack(testlist[ptr],&write); + vorbis_staticbook_pack(testlist[ptr],&write); fprintf(stderr,"Codebook size %ld bytes... ",_oggpack_bytes(&write)); for(i=0;i<TESTSIZE;i+=TESTDIM) vorbis_book_encodev(&c,qv+i,&write); @@ -564,7 +564,7 @@ int main(){ /* transfer the write data to a read buffer and unpack/read */ _oggpack_readinit(&read,_oggpack_buffer(&write),_oggpack_bytes(&write)); - if(vorbis_book_unpack(&read,&s)){ + if(vorbis_staticbook_unpack(&read,&s)){ fprintf(stderr,"Error unpacking codebook.\n"); exit(1); } |
