]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
If sox fails when processing a voicemail, don't delete the original file.
authorSean Bright <sean@malleable.com>
Wed, 4 May 2011 16:08:50 +0000 (16:08 +0000)
committerSean Bright <sean@malleable.com>
Wed, 4 May 2011 16:08:50 +0000 (16:08 +0000)
(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.4@316707 65c4cc65-6c06-0410-ace0-fbb531ad65f3

apps/app_voicemail.c

index 456871f25ef53d32577ac2dc396cb7e9da10454c..b6be96b34046351a3d0dddf9a714da1f0b7e4572 100644 (file)
@@ -3641,7 +3641,8 @@ plain_message:
                char *ctype = (!strcasecmp(format, "ogg")) ? "application/" : "audio/x-";
                char tmpdir[256], newtmp[256];
                int tmpfd = -1;
-       
+               int soxstatus = 0;
+
                if (vmu->volgain < -.001 || vmu->volgain > .001) {
                        create_dirpath(tmpdir, sizeof(tmpdir), vmu->context, vmu->mailbox, "tmp");
                        snprintf(newtmp, sizeof(newtmp), "%s/XXXXXX", tmpdir);
@@ -3650,7 +3651,6 @@ plain_message:
                        if (option_debug > 2)
                                ast_log(LOG_DEBUG, "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;
@@ -3673,7 +3673,9 @@ plain_message:
                base_encode(fname, p);
                fprintf(p, ENDL "--%s--" ENDL "." ENDL, bound);
                if (tmpfd > -1) {
-                       unlink(fname);
+                       if (soxstatus == 0) {
+                               unlink(fname);
+                       }
                        close(tmpfd);
                        unlink(newtmp);
                }