summaryrefslogtreecommitdiff
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2006-01-21 17:50:04 +0000
committerRussell Bryant <russell@russellbryant.com>2006-01-21 17:50:04 +0000
commit9fa6eb5e07ad37d5a9043b5f4d23431d58c88325 (patch)
treea0057e266407ad019e0b495dd566584d47b50da5 /apps/app_voicemail.c
parentfbdc8ce317eacca50018748cb850ef317964af21 (diff)
revert my pass through the tree to remove checks of the result of ast_strdupa
(revisions 8378 through 8381) git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8387 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c83
1 files changed, 54 insertions, 29 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index bf6e93a8f..e46735d03 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -3284,23 +3284,28 @@ static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu,
snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context);
/* Attach only the first format */
- stringp = fmt = ast_strdupa(fmt);
- strsep(&stringp, "|");
-
- if (!ast_strlen_zero(vmu->email)) {
- int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
- char *myserveremail = serveremail;
- attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
- if (!ast_strlen_zero(vmu->serveremail))
- myserveremail = vmu->serveremail;
- sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category);
- }
-
- if (!ast_strlen_zero(vmu->pager)) {
- char *myserveremail = serveremail;
- if (!ast_strlen_zero(vmu->serveremail))
- myserveremail = vmu->serveremail;
- sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu, category);
+ fmt = ast_strdupa(fmt);
+ if (fmt) {
+ stringp = fmt;
+ strsep(&stringp, "|");
+
+ if (!ast_strlen_zero(vmu->email)) {
+ int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
+ char *myserveremail = serveremail;
+ attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
+ if (!ast_strlen_zero(vmu->serveremail))
+ myserveremail = vmu->serveremail;
+ sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category);
+ }
+
+ if (!ast_strlen_zero(vmu->pager)) {
+ char *myserveremail = serveremail;
+ if (!ast_strlen_zero(vmu->serveremail))
+ myserveremail = vmu->serveremail;
+ sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu, category);
+ }
+ } else {
+ ast_log(LOG_ERROR, "Out of memory\n");
}
if (ast_test_flag(vmu, VM_DELETE)) {
@@ -5053,6 +5058,11 @@ static int vm_execmain(struct ast_channel *chan, void *data)
);
parse = ast_strdupa(data);
+ if (!parse) {
+ ast_log(LOG_ERROR, "Out of memory!\n");
+ LOCAL_USER_REMOVE(u);
+ return -1;
+ }
AST_STANDARD_APP_ARGS(args, parse);
@@ -5638,6 +5648,11 @@ static int vm_box_exists(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
box = ast_strdupa(data);
+ if (!box) {
+ ast_log(LOG_ERROR, "Out of memory\n");
+ LOCAL_USER_REMOVE(u);
+ return -1;
+ }
AST_STANDARD_APP_ARGS(args, box);
@@ -5675,6 +5690,10 @@ static int vmauthenticate(struct ast_channel *chan, void *data)
if (s) {
s = ast_strdupa(s);
+ if (!s) {
+ ast_log(LOG_ERROR, "Out of memory\n");
+ return -1;
+ }
user = strsep(&s, "|");
options = strsep(&s, "|");
if (user) {
@@ -6121,22 +6140,28 @@ static int load_config(void)
if ((z = ast_malloc(sizeof(*z)))) {
char *msg_format, *timezone;
msg_format = ast_strdupa(var->value);
- timezone = strsep(&msg_format, "|");
- if (msg_format) {
- ast_copy_string(z->name, var->name, sizeof(z->name));
- ast_copy_string(z->timezone, timezone, sizeof(z->timezone));
- ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
- z->next = NULL;
- if (zones) {
- zonesl->next = z;
- zonesl = z;
+ if (msg_format != NULL) {
+ timezone = strsep(&msg_format, "|");
+ if (msg_format) {
+ ast_copy_string(z->name, var->name, sizeof(z->name));
+ ast_copy_string(z->timezone, timezone, sizeof(z->timezone));
+ ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
+ z->next = NULL;
+ if (zones) {
+ zonesl->next = z;
+ zonesl = z;
+ } else {
+ zones = z;
+ zonesl = z;
+ }
} else {
- zones = z;
- zonesl = z;
+ ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
+ free(z);
}
} else {
- ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
+ ast_log(LOG_WARNING, "Out of memory while reading voicemail config\n");
free(z);
+ return -1;
}
} else {
return -1;