shithub: sox

Download patch

ref: f39c574bc423fd5b12bd6510264512f5d5366183
parent: 7d3f38007a1eeaf5ab7669aba0d2a7e4d3def57e
author: Chris Bagwell <chris@cnpbagwell.com>
date: Mon Dec 22 05:45:59 EST 2014

More checks for invalid MS ADPCM blocks.

If block doesn't exacty match blockAlign then do not allow
number of samples in invalid size block to ever be more than
what WAV header defined as samplesPerBlock.

--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,8 @@
   o Add reading support for RF64 WAV files. (Dave Lambley)
   o Work around for libsndfile created RF64 files with invalid
     sizes. (Dave Lambley)
+  o Detect MS ADPCM WAV files with invalid blocks. (cbagwell)
+  o Detect Sphere files with invalid header sizes. (cbagwell)
 
 Effects:
 
--- a/src/wav.c
+++ b/src/wav.c
@@ -168,7 +168,7 @@
         /* work with partial blocks.  Specs say it should be null */
         /* padded but I guess this is better than trailing quiet. */
         samplesThisBlock = lsx_ms_adpcm_samples_in((size_t)0, (size_t)ft->signal.channels, bytesRead, (size_t)0);
-        if (samplesThisBlock == 0)
+        if (samplesThisBlock == 0 || samplesThisBlock > wav->samplesPerBlock)
         {
             lsx_warn("Premature EOF on .wav input file");
             return 0;