]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Merged revisions 316707 via svnmerge from
authorSean Bright <sean@malleable.com>
Wed, 4 May 2011 16:10:59 +0000 (16:10 +0000)
committerSean Bright <sean@malleable.com>
Wed, 4 May 2011 16:10:59 +0000 (16:10 +0000)
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r316707 | seanbright | 2011-05-04 12:08:50 -0400 (Wed, 04 May 2011) | 8 lines

  If sox fails when processing a voicemail, don't delete the original file.

  (closes issue #18111)
  Reported by: sysreq
  Patches:
        issue18111_trunk.patch uploaded by seanbright (license 71)
  Tested by: seanbright
........

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.6.2@316708 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 9a78f2c63b379411b24f8de2f1477864603a960f..19a8a74bcf24df467c5bcfa73a10a43dff63522c 100644 (file)
@@ -4582,6 +4582,7 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
        char fname[256];
        char tmpcmd[256];
        int tmpfd = -1;
+       int soxstatus = 0;
 
        /* Eww. We want formats to tell us their own MIME type */
        char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
@@ -4593,7 +4594,6 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
                chmod(newtmp, VOICEMAIL_FILE_MODE & ~my_umask);
                ast_debug(3, "newtmp: %s\n", newtmp);
                if (tmpfd > -1) {
-                       int soxstatus;
                        snprintf(tmpcmd, sizeof(tmpcmd), "sox -v %.4f %s.%s %s.%s", vmu->volgain, attach, format, newtmp, format);
                        if ((soxstatus = ast_safe_system(tmpcmd)) == 0) {
                                attach = newtmp;
@@ -4621,7 +4621,9 @@ static int add_email_attachment(FILE *p, struct ast_vm_user *vmu, char *format,
        if (last)
                fprintf(p, ENDL ENDL "--%s--" ENDL "." ENDL, bound);
        if (tmpfd > -1) {
-               unlink(fname);
+               if (soxstatus == 0) {
+                       unlink(fname);
+               }
                close(tmpfd);
                unlink(newtmp);
        }