shithub: sox

Download patch

ref: 523b28aa937d505bfa0d7a099d512f9221bd4573
parent: cef9d9ade1eb912a427ddaecaa166956657c98d2
author: robs <robs>
date: Thu Nov 1 17:26:20 EDT 2007

attempt to fix empty MARK chunk

--- a/src/aiff.c
+++ b/src/aiff.c
@@ -187,7 +187,11 @@
                 else if (strncmp(buf, "MARK", 4) == 0) {
                         /* MARK chunk */
                         sox_readdw(ft, &chunksize);
-                        sox_readw(ft, &nmarks);
+                        if (chunksize >= sizeof(nmarks)) {
+                          sox_readw(ft, &nmarks);
+                          chunksize -= sizeof(nmarks);
+                        }
+                        else nmarks = 0;
 
                         /* Some programs like to always have a MARK chunk
                          * but will set number of marks to 0 and force
@@ -202,8 +206,6 @@
                         if (nmarks > 32)
                             nmarks = 32;
 
-                        if (chunksize > 2)
-                            chunksize -= 2;
                         for(i = 0; i < nmarks && chunksize; i++) {
                                 unsigned char len, read_len, tmp_c;