[xiph-commits] r16182 - trunk/vorbis/lib

xiphmont at svn.xiph.org xiphmont at svn.xiph.org
Wed Jun 24 20:53:49 PDT 2009


Author: xiphmont
Date: 2009-06-24 20:53:49 -0700 (Wed, 24 Jun 2009)
New Revision: 16182

Modified:
   trunk/vorbis/lib/floor1.c
Log:
Second half of fix to Mozilla BZ # 5000254: sanity check the floor 1
post list to reject files with repeated values that would result in
floor line segments with zero length.



Modified: trunk/vorbis/lib/floor1.c
===================================================================
--- trunk/vorbis/lib/floor1.c	2009-06-25 03:39:41 UTC (rev 16181)
+++ trunk/vorbis/lib/floor1.c	2009-06-25 03:53:49 UTC (rev 16182)
@@ -120,6 +120,9 @@
   }
 }
 
+static int icomp(const void *a,const void *b){
+  return(**(int **)a-**(int **)b);
+}
 
 static vorbis_info_floor *floor1_unpack (vorbis_info *vi,oggpack_buffer *opb){
   codec_setup_info     *ci=vi->codec_setup;
@@ -164,6 +167,17 @@
   info->postlist[0]=0;
   info->postlist[1]=1<<rangebits;
 
+  /* don't allow repeated values in post list as they'd result in
+     zero-length segments */
+  {
+    int *sortpointer[VIF_POSIT+2];
+    for(j=0;j<count+2;j++)sortpointer[j]=info->postlist+j;
+    qsort(sortpointer,count+2,sizeof(*sortpointer),icomp);
+
+    for(j=1;j<count+2;j++)
+      if(*sortpointer[j-1]==*sortpointer[j])goto err_out;
+  }
+
   return(info);
 
  err_out:
@@ -171,10 +185,6 @@
   return(NULL);
 }
 
-static int icomp(const void *a,const void *b){
-  return(**(int **)a-**(int **)b);
-}
-
 static vorbis_look_floor *floor1_look(vorbis_dsp_state *vd,
                                       vorbis_info_floor *in){
 



More information about the commits mailing list