[Home]

Summary:ASTERISK-03422: [PATCH] Bug in ast_write_file produces invalid WAV files when appending audio.
Reporter:critch (critch)Labels:
Date Opened:2005-02-02 16:40:49.000-0600Date Closed:2008-01-15 15:24:34.000-0600
Priority:MinorRegression?No
Status:Closed/CompleteComponents:Core/General
Versions:Frequency of
Occurrence
Related
Issues:
Environment:Attachments:( 0) file.diff
Description:In my original patch to allow record from location functionality, I only tested with GSM files. This bug was not noticed until some time later and wasn't severe enough to jump on back then,

Anyways, the O_APPEND flag to open causes the format_wav*.c functions to not be able to seek to the header loacation and fix the headers. O_APPEND is still being passed as a way to turn off the default behaviour of O_TRUNC, but is removed from the flag list so the headers can be properly written.

Patch provided is for an older version but the code should apply to CVS HEAD and STABLE as the bug was present from before the split.

****** ADDITIONAL INFORMATION ******

Index: file.c
===================================================================
RCS file: /usr/cvsroot/asterisk/file.c,v
retrieving revision 1.39
diff -u -r1.39 file.c
--- file.c      6 Apr 2004 22:17:31 -0000       1.39
+++ file.c      2 Feb 2005 22:25:06 -0000
@@ -812,8 +812,12 @@
               return NULL;
       }
       /* set the O_TRUNC flag if and only if there is no O_APPEND specified */
-       if (!(flags & O_APPEND))
+       if (flags & O_APPEND){
+               /* We really can't use O_APPEND as it will break WAV header updates */
+               flags &= ~O_APPEND;
+       }else{
               myflags = O_TRUNC;
+       }

       myflags |= O_WRONLY | O_CREAT;
Comments:By: Russell Bryant (russell) 2005-02-02 17:29:25.000-0600

For CVS head, it is preferred if you use the flag macros in utils.h to do those flag operations.

By: twisted (twisted) 2005-02-02 17:47:50.000-0600

This is not MAJOR - demoting to minor.  Also, please confirm disclaimer.  I also noticed that cvs revision of file.c is at 1.55, whereas you diffed against 1.39.  Can you please verify that this patch is for latest CVS?

By: critch (critch) 2005-02-02 20:29:31.000-0600

I have a disclaimer on file. In fact, If it wasn't for my contribution, this bug wouldn't exist. I am the Steven Critchfield that is listed in the credits file already.

I'll look into the flag macros. I just don't have that new of a install in production to verify it works.

As for if it is for current CVS. That portion of file.c is still the same and still exhibits the same bug.

By: Mark Spencer (markster) 2005-02-02 23:35:06.000-0600

Fixed in CVS with minor formatting fixups.  These flags are used with open() so I don't think the use of the flag macros is really necessary in this case.

By: Russell Bryant (russell) 2005-02-06 21:53:09.000-0600

fixed in 1.0

By: Digium Subversion (svnbot) 2008-01-15 15:24:15.000-0600

Repository: asterisk
Revision: 4958

U   trunk/file.c

------------------------------------------------------------------------
r4958 | markster | 2008-01-15 15:24:14 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix wav append mode (bug ASTERISK-3422)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=4958

By: Digium Subversion (svnbot) 2008-01-15 15:24:34.000-0600

Repository: asterisk
Revision: 4975

U   branches/v1-0/file.c

------------------------------------------------------------------------
r4975 | russell | 2008-01-15 15:24:33 -0600 (Tue, 15 Jan 2008) | 2 lines

Fix wav append mode (bug ASTERISK-3422)

------------------------------------------------------------------------

http://svn.digium.com/view/asterisk?view=rev&revision=4975