aboutsummaryrefslogtreecommitdiffstats
path: root/apps/app_voicemail.c
diff options
context:
space:
mode:
authormmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-06 20:25:11 +0000
committermmichelson <mmichelson@f38db490-d61c-443f-a65b-d21fe96a405b>2007-12-06 20:25:11 +0000
commit09e8e780bef8abf3fb8c8f34b843b5baf654d2f3 (patch)
treecb110b46c06c6e009f756129f4021d7bea02ddf9 /apps/app_voicemail.c
parentf1912af11e18b49a7747fa544f42e770444c45a2 (diff)
IMAP storage did not honor the maxmsg setting in voicemail.conf, and it also had the possibility
of crashing if a user had more than 256 messages in their voicemail. This patch kills two birds with one stone by adding maxmsg support and also setting a hard limit on the number of messages at 255 so that the crashes cannot happen. (closes issue #11101, reported by Skavin, patched by me) git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@91541 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_voicemail.c')
-rw-r--r--apps/app_voicemail.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/apps/app_voicemail.c b/apps/app_voicemail.c
index b124de468..490ecf108 100644
--- a/apps/app_voicemail.c
+++ b/apps/app_voicemail.c
@@ -160,7 +160,11 @@ static struct vmstate *vmstates = NULL;
#define INTRO "vm-intro"
#define MAXMSG 100
+#ifndef IMAP_STORAGE
#define MAXMSGLIMIT 9999
+#else
+#define MAXMSGLIMIT 255
+#endif
#define BASEMAXINLINE 256
#define BASELINELEN 72
@@ -2560,6 +2564,10 @@ static int copy_message(struct ast_channel *chan, struct ast_vm_user *vmu, int i
char dest[256];
struct vm_state *sendvms = NULL, *destvms = NULL;
char messagestring[10]; /*I guess this could be a problem if someone has more than 999999999 messages...*/
+ if(msgnum >= recip->maxmsg) {
+ ast_log(LOG_WARNING, "Unable to copy mail, mailbox %s is full\n", recip->mailbox);
+ return -1;
+ }
if(!(sendvms = get_vm_state_by_imapuser(vmu->imapuser, 2)))
{
ast_log(LOG_ERROR, "Couldn't get vm_state for originator's mailbox!!\n");
@@ -3006,6 +3014,12 @@ static int leave_voicemail(struct ast_channel *chan, char *ext, struct leave_vm_
ast_play_and_wait(chan, "vm-mailboxfull");
return -1;
}
+ /* Check if we have exceeded maxmsg */
+ if (msgnum >= vmu->maxmsg) {
+ ast_log(LOG_WARNING, "Unable to leave message since we will exceed the maximum number of messages allowed (%u > %u)\n", msgnum, vmu->maxmsg);
+ ast_play_and_wait(chan, "vm-mailboxfull");
+ return -1;
+ }
/* here is a big difference! We add one to it later */
if (option_debug > 2)
ast_log(LOG_DEBUG, "Messagecount set to %d\n",msgnum);