shithub: sox

Download patch

ref: 6c020bad428f04341aeb8bc4bed545b6ffc20ce5
parent: c99441ba41ca6def848417d57a8109f2b51277c1
author: cbagwell <cbagwell>
date: Sun Nov 28 17:12:54 EST 2004

Abort chunk reads on invalid seeks.

--- a/INSTALL
+++ b/INSTALL
@@ -53,11 +53,24 @@
 If this library fails to compile on your system, you can specify
 --disable-gsm to prevent it from being compiled in.
 
-SoX can make use of Ogg Vorbis libraries to play and record Ogg
-Vorbis files.  If this library is installed in a non-standard location
-in your system then you can use the CPPFLAGS and LDFLAGS variables
-to allow configure to find this library.  For examle,
-"./configure CPPFLAGS=-I/home/sox/include LDFLAGS=-L/home/sox/lib".
+SoX can make use of Ogg Vorbis libraries to read and write Ogg
+Vorbis files.  Normally, the configure script will auto detect
+this library and enable support for Ogg Vorbis.  Ogg Vorbis library 
+can be obtained from http://www.vorbis.com
+
+SoX can make use of MP3 libraries to read and write MP3 files.
+Normally, the configure script will auto detect these libraries and
+enable support for MP3.  SoX requires libmad for reading MP3 files
+and lame for writing MP3 files.  Libmad can be obtained from
+http://www.underbit.com/products/mad/ and lame can be obtained from
+http://mitiok.cjb.net/
+
+If any libraries are installed in a non-standard locations in your 
+system then you can use the CPPFLAGS and LDFLAGS variables to allow 
+configure to find 
+them.  For example:
+
+./configure CPPFLAGS="-I/home/sox/include -I/usr/local/multimedia/include" LDFLAGS="-L/home/sox/lib -L/usr/local/multimedia/lib"
 
 If you're not processing lots of u-law or A-law files and would
 like to save around 64K of memory when SoX is executed then you
--- a/README
+++ b/README
@@ -63,7 +63,7 @@
   o Multi-band compander
   o Pan sound between channels
   o Apply a phaser effect
-  o Change the pitch of a sound file without effecting its speed
+  o Change the pitch of a sound file without affecting its speed
   o Repeat audio data
   o Change sampling rates using several different algorithms. A
      'resample' and 'polyphase' effect use high-grade signal rate
@@ -74,7 +74,7 @@
   o Change the speed of samples being played (like speeding up the motor
     on a tape recorder)
   o Display general stats on a sound sample
-  o Stretch/shorten the duration of a sound file (without effecting pitch).
+  o Stretch/shorten the duration of a sound file (without affecting pitch).
   o Swap stereo channels
   o Create sounds with a simple synthesizer.
   o Trim audio data from beginning and end of file.
--- a/src/wav.c
+++ b/src/wav.c
@@ -403,17 +403,23 @@
     {
         if (st_reads(ft, magic, 4) == ST_EOF)
         {
-            st_fail_errno(ft,ST_EHDR,"WAVE file has missing %s chunk", Label);
+            st_fail_errno(ft, ST_EHDR, "WAVE file has missing %s chunk", 
+                          Label);
             return ST_EOF;
         }
         st_readdw(ft, &tmp_len);
         len = tmp_len;
-        st_report("Chunk %s",magic);
+        st_report("WAV Chunk %s", magic);
+
         if (strncmp(Label, magic, 4) == 0)
-            break;              /* Found the data chunk */
+            break; /* Found the data chunk */
 
-        
-        st_seek(ft, len, SEEK_CUR);     /* skip to next chunk */
+        /* skip to next chunk */
+        if (st_seek(ft, len, SEEK_CUR) != ST_SUCCESS)
+        {
+            st_fail_errno(ft,ST_EHDR, "WAV chunk appears to have invalid size %d.", len);
+            return ST_EOF;
+        }
     }
     return len;
 }
@@ -835,7 +841,11 @@
 
     /* Now look for the wave data chunk */
     dwDataLength = len = findChunk(ft, "data");
-    /* findChunk() only returns if chunk was found */
+    if (len == ST_EOF)
+    {
+        st_fail_errno(ft, ST_EOF, "Could not find data chunk.");
+        return ST_EOF;
+    }
 
     /* Data starts here */
     wav->dataStart = st_tell(ft);
@@ -916,8 +926,9 @@
          * doubt any machine writing Cool Edit Chunks writes them at an odd 
          * offset */
         len = (len + 1) & ~1;
-        st_seek(ft, len, SEEK_CUR);
-        if( findChunk(ft, "LIST") != ST_EOF){
+        if (st_seek(ft, len, SEEK_CUR) == ST_SUCCESS &&
+            findChunk(ft, "LIST") != ST_EOF)
+        {
             wav->found_cooledit = 1;
             ft->comment = (char*)malloc(256);
             /* Initialize comment to a NULL string */