summaryrefslogtreecommitdiff
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authorKinsey Moore <kmoore@digium.com>2012-07-31 20:21:43 +0000
committerKinsey Moore <kmoore@digium.com>2012-07-31 20:21:43 +0000
commit9b16c8b0f6c3b6310e303411421bfcb16b26c3c4 (patch)
tree273c31a834a21bd2239ec6b83cd35c602ea25d26 /apps/app_voicemail.c
parent6c23a60f802e7708389b1a6463a40dc0500512bd (diff)
Clean up and ensure proper usage of alloca()
This replaces all calls to alloca() with ast_alloca() which calls gcc's __builtin_alloca() to avoid BSD semantics and removes all NULL checks on memory allocated via ast_alloca() and ast_strdupa(). (closes issue ASTERISK-20125) Review: https://reviewboard.asterisk.org/r/2032/ Patch-by: Walter Doekes (wdoekes) ........ Merged revisions 370642 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 370643 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index 6d0160325..a4deb9b9b 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -1096,7 +1096,7 @@ static int inprocess_cmp_fn(void *obj, void *arg, int flags)
static int inprocess_count(const char *context, const char *mailbox, int delta)
{
- struct inprocess *i, *arg = alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2);
+ struct inprocess *i, *arg = ast_alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2);
arg->context = arg->mailbox + strlen(mailbox) + 1;
strcpy(arg->mailbox, mailbox); /* SAFE */
strcpy(arg->context, context); /* SAFE */
@@ -1719,10 +1719,10 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
}
value = strstr(tmp, ",");
if (!value) {
- new = alloca(strlen(newpassword)+1);
+ new = ast_alloca(strlen(newpassword)+1);
sprintf(new, "%s", newpassword);
} else {
- new = alloca((strlen(value) + strlen(newpassword) + 1));
+ new = ast_alloca((strlen(value) + strlen(newpassword) + 1));
sprintf(new, "%s%s", newpassword, value);
}
if (!(cat = ast_category_get(cfg, category))) {
@@ -1757,7 +1757,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
} else {
var = NULL;
}
- new = alloca(strlen(newpassword) + 1);
+ new = ast_alloca(strlen(newpassword) + 1);
sprintf(new, "%s", newpassword);
if (!(cat = ast_category_get(cfg, category))) {
ast_debug(4, "failed to get category!\n");
@@ -4472,7 +4472,7 @@ static int vm_delete(char *file)
int txtsize = 0;
txtsize = (strlen(file) + 5)*sizeof(char);
- txt = alloca(txtsize);
+ txt = ast_alloca(txtsize);
/* Sprintf here would safe because we alloca'd exactly the right length,
* but trying to eliminate all sprintf's anyhow
*/
@@ -8782,7 +8782,7 @@ static int vm_play_folder_name_gr(struct ast_channel *chan, char *box)
int cmd;
char *buf;
- buf = alloca(strlen(box) + 2);
+ buf = ast_alloca(strlen(box) + 2);
strcpy(buf, box);
strcat(buf, "s");
@@ -11697,7 +11697,7 @@ static int append_mailbox(const char *context, const char *box, const char *data
read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
}
- mailbox_full = alloca(strlen(box) + strlen(context) + 1);
+ mailbox_full = ast_alloca(strlen(box) + strlen(context) + 1);
strcpy(mailbox_full, box);
strcat(mailbox_full, "@");
strcat(mailbox_full, context);
@@ -15229,12 +15229,7 @@ static int vm_msg_forward(const char *from_mailbox,
goto vm_forward_cleanup;
}
- if (!(msg_nums = alloca(sizeof(int) * num_msgs)))
- {
- ast_log(LOG_ERROR, "Unable to allocate stack space! Expect awful things!\n");
- res = -1;
- goto vm_forward_cleanup;
- }
+ msg_nums = ast_alloca(sizeof(int) * num_msgs);
if ((res = message_range_and_existence_check(&from_vms, msg_ids, num_msgs, msg_nums, vmu) < 0)) {
goto vm_forward_cleanup;
@@ -15359,11 +15354,7 @@ static int vm_msg_move(const char *mailbox,
goto vm_move_cleanup;
}
- if (!(old_msg_nums = alloca(sizeof(int) * num_msgs))) {
- ast_log(LOG_ERROR, "Unable to allocate stack space! Expect awful things!\n");
- res = -1;
- goto vm_move_cleanup;
- }
+ old_msg_nums = ast_alloca(sizeof(int) * num_msgs);
if ((res = message_range_and_existence_check(&vms, old_msg_ids, num_msgs, old_msg_nums, vmu)) < 0) {
goto vm_move_cleanup;
@@ -15464,11 +15455,7 @@ static int vm_msg_remove(const char *mailbox,
goto vm_remove_cleanup;
}
- if (!(msg_nums = alloca(sizeof(int) * num_msgs))) {
- ast_log(LOG_ERROR, "Unable to allocate stack space! Expect awful things\n");
- res = -1;
- goto vm_remove_cleanup;
- }
+ msg_nums = ast_alloca(sizeof(int) * num_msgs);
if ((res = message_range_and_existence_check(&vms, msgs, num_msgs, msg_nums, vmu)) < 0) {
goto vm_remove_cleanup;