From: Sean Bright Date: Wed, 4 May 2011 16:08:50 +0000 (+0000) Subject: If sox fails when processing a voicemail, don't delete the original file. X-Git-Tag: 1.4.42-rc1~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a864430b0bf6d105c9d27fc4dd7d2a89f3dc3eab;p=thirdparty%2Fasterisk.git 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.4@316707 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c index 456871f25e..b6be96b340 100644 --- a/apps/app_voicemail.c +++ b/apps/app_voicemail.c @@ -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); }