Index: apps/app_voicemail.c =================================================================== --- apps/app_voicemail.c (revision 88525) +++ apps/app_voicemail.c (working copy) @@ -160,7 +160,11 @@ #define INTRO "vm-intro" #define MAXMSG 100 +#ifndef IMAP_STORAGE #define MAXMSGLIMIT 9999 +#else +#define MAXMSGLIMIT 255 +#endif #define BASEMAXINLINE 256 #define BASELINELEN 72 @@ -2545,6 +2549,10 @@ 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"); @@ -2991,6 +2999,12 @@ 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);