shithub: sox

Download patch

ref: 0e45c03fe9d6baef5b561e183cb3263a91a5786a
parent: 4a4ea33edbca5972a1ed8933cc3512c7302fa67a
author: cbagwell <cbagwell>
date: Tue Mar 4 18:41:59 EST 2008

Foritified sox was crashing in sf handler on writes.  Simple fix
to work around it.  Probably the crash was pointing out we are
writing corrupt headers in the past and only SoX can read/write
SF files from the same machine.  I may be kidding myself about
why this fix is working though.

--- a/src/sf.c
+++ b/src/sf.c
@@ -197,7 +197,7 @@
         /* between different coverts and not rely on memory contents */
         memset (&sfhead, 0, sizeof(SFHEADER));
         memcpy(&sfhead.sfinfo, &sf->info, sizeof(struct sfinfo));
-        sfcodep = (SFCODE *) (&sfhead.sfinfo + 1);
+        sfcodep = (SFCODE *) (&sfhead.filler[SF_INFO_LEN+1]);
         sfcodep->code = SF_COMMENT;
         sfcodep->bsize = strlen(comment) + sizeof(SFCODE);
         while (sfcodep->bsize % 4)
@@ -209,8 +209,6 @@
         sfcodep->code = SF_END;
         sfcodep->bsize = sizeof(SFCODE);
         sfcharp = (char *) sfcodep + sizeof(SFCODE);
-        while(sfcharp < (char *) &sfhead + SIZEOF_HEADER)
-                *sfcharp++ = '\0';
         sox_writebuf(ft, &sfhead, sizeof(SFHEADER));
 
         return(SOX_SUCCESS);
--- a/src/sfircam.h
+++ b/src/sfircam.h
@@ -80,6 +80,10 @@
  * sf_magic is for backward compatibility; it should be SF_MAGIC as defined
  * above.
  */
+
+/* Define this value to get around by padding issues. */
+#define SF_INFO_LEN 16
+
 struct sfinfo {
     union magic_union {
         struct {