[asterisk-commits] anthonyl: branch anthonyl/voicemail-odbc r48460 -
/team/anthonyl/voicemail-od...
asterisk-commits at lists.digium.com
asterisk-commits at lists.digium.com
Wed Dec 13 18:11:38 MST 2006
Author: anthonyl
Date: Wed Dec 13 19:11:37 2006
New Revision: 48460
URL: http://svn.digium.com/view/asterisk?view=rev&rev=48460
Log:
added create_dirpath checks before RETRIEVE
Modified:
team/anthonyl/voicemail-odbc/apps/app_voicemail.c
Modified: team/anthonyl/voicemail-odbc/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/team/anthonyl/voicemail-odbc/apps/app_voicemail.c?view=diff&rev=48460&r1=48459&r2=48460
==============================================================================
--- team/anthonyl/voicemail-odbc/apps/app_voicemail.c (original)
+++ team/anthonyl/voicemail-odbc/apps/app_voicemail.c Wed Dec 13 19:11:37 2006
@@ -70,6 +70,7 @@
#include "asterisk/localtime.h"
#include "asterisk/cli.h"
#include "asterisk/utils.h"
+#include "asterisk/astmm.h"
#ifdef USE_ODBC_STORAGE
#include "asterisk/res_odbc.h"
#endif
@@ -1806,7 +1807,7 @@
fclose(p);
snprintf(tmp2, sizeof(tmp2), "( %s < %s ; rm -f %s ) &", mailcmd, tmp, tmp);
ast_safe_system(tmp2);
- ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
+ ast_log(LOG_DEBUG, "Sent mail to %s with command '%s'\n", vmu->email, mailcmd);
} else {
ast_log(LOG_WARNING, "Unable to launch '%s'\n", mailcmd);
return -1;
@@ -1938,12 +1939,26 @@
localtime_r(&t,&tm);
return strftime(s, len, "%a %b %e %r %Z %Y", &tm);
}
-
+
static int invent_message(struct ast_channel *chan, char *context, char *ext, int busy, char *ecodes)
{
int res;
char fn[256];
+ char *dest;
+
snprintf(fn, sizeof(fn), "%s%s/%s/greet", VM_SPOOL_DIR, context, ext);
+
+ if (!(dest = malloc(1024))) {
+ ast_log(LOG_WARNING, "Failed memory allocation\n");
+ return -1;
+ }
+
+ if (!(res=create_dirpath(dest,1024,context,ext,"greet"))) {
+ ast_log(LOG_WARNING, "Failed to make directory(%s)\n", fn);
+ return -1;
+ }
+ free(dest);
+
RETRIEVE(fn, -1);
if (ast_fileexists(fn, NULL, NULL) > 0) {
res = ast_streamfile(chan, fn, chan->language);
@@ -2402,6 +2417,7 @@
struct ast_vm_user *vmu;
struct ast_vm_user svm;
char *category = NULL;
+ char *dest = NULL;
ast_copy_string(tmp, ext, sizeof(tmp));
ext = tmp;
@@ -2429,16 +2445,30 @@
return res;
}
+ if (!(dest=malloc(1024))) {
+ ast_log(LOG_WARNING, "Failed to allocate memory\n");
+ return -1;
+ }
+
/* Setup pre-file if appropriate */
if (strcmp(vmu->context, "default"))
snprintf(ext_context, sizeof(ext_context), "%s@%s", ext, vmu->context);
else
ast_copy_string(ext_context, vmu->context, sizeof(ext_context));
- if (ast_test_flag(options, OPT_BUSY_GREETING))
+ if (ast_test_flag(options, OPT_BUSY_GREETING)) {
+ res = create_dirpath(dest, 1024, vmu->context, ext, "busy");
snprintf(prefile, sizeof(prefile), "%s%s/%s/busy", VM_SPOOL_DIR, vmu->context, ext);
- else if (ast_test_flag(options, OPT_UNAVAIL_GREETING))
+ }
+ else if (ast_test_flag(options, OPT_UNAVAIL_GREETING)) {
+ res = create_dirpath(dest, 1024, vmu->context, ext, "unavail");
snprintf(prefile, sizeof(prefile), "%s%s/%s/unavail", VM_SPOOL_DIR, vmu->context, ext);
+ }
snprintf(tempfile, sizeof(tempfile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, ext);
+ if (!(res=create_dirpath(dest, 1024, vmu->context, ext, "temp"))) {
+ ast_log(LOG_WARNING, "Failed to make directory (%s)\n", tempfile);
+ return -1;
+ }
+ free(dest);
RETRIEVE(tempfile, -1);
if (ast_fileexists(tempfile, NULL, NULL) > 0)
ast_copy_string(prefile, tempfile, sizeof(prefile));
@@ -3442,7 +3472,7 @@
char username[70]="";
int res = 0, cmd = 0;
struct ast_vm_user *receiver = NULL, *extensions = NULL, *vmtmp = NULL, *vmfree;
- char *stringp, *s;
+ char *stringp, *s, *dest;
int saved_messages = 0, found = 0;
int valid_extensions = 0;
@@ -3573,8 +3603,12 @@
} else {
/* Forward VoiceMail */
long duration = 0;
-
- RETRIEVE(dir, curmsg);
+ if (!(dest=malloc(1024))) {
+ ast_log(LOG_WARNING, "Memory allocation failed.\n");
+ return -1;
+ }
+
+ RETRIEVE(dir, curmsg);
cmd = vm_forwardoptions(chan, sender, dir, curmsg, vmfmts, context, record_gain, &duration);
if (!cmd) {
while (!res && vmtmp) {
@@ -3787,7 +3821,7 @@
static int play_message(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms)
{
- int res = 0;
+ int res = 0;
char filename[256],*origtime, *cid, *context, *duration;
char *category;
struct ast_config *msg_cfg;
@@ -4789,12 +4823,14 @@
static int vm_tempgreeting(struct ast_channel *chan, struct ast_vm_user *vmu, struct vm_state *vms, char *fmtc, signed char record_gain)
{
+ int res;
int cmd = 0;
int retries = 0;
int duration = 0;
char prefile[256]="";
unsigned char buf[256];
int bytes=0;
+ char *dest;
if (adsi_available(chan))
{
@@ -4806,6 +4842,14 @@
adsi_transmit_message(chan, buf, bytes, ADSI_MSG_DISPLAY);
}
snprintf(prefile,sizeof(prefile), "%s%s/%s/temp", VM_SPOOL_DIR, vmu->context, vms->username);
+ if (!(dest=malloc(1024))) {
+ ast_log(LOG_WARNING, "Failed memory allocation.\n");
+ return -1;
+ }
+ if (!(res=create_dirpath(dest, 1024, vmu->context, vms->username, "temp"))) {
+ ast_log(LOG_WARNING, "Failed to create directory (%s).\n", prefile);
+ return -1;
+ }
while((cmd >= 0) && (cmd != 't')) {
if (cmd)
retries = 0;
More information about the asterisk-commits
mailing list