[asterisk-commits] mogorman: trunk r42283 - /trunk/apps/app_voicemail.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Thu Sep 7 10:05:52 MST 2006


Author: mogorman
Date: Thu Sep  7 12:05:51 2006
New Revision: 42283

URL: http://svn.digium.com/view/asterisk?rev=42283&view=rev
Log:
protect curhst and curusr

Modified:
    trunk/apps/app_voicemail.c

Modified: trunk/apps/app_voicemail.c
URL: http://svn.digium.com/view/asterisk/trunk/apps/app_voicemail.c?rev=42283&r1=42282&r2=42283&view=diff
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Thu Sep  7 12:05:51 2006
@@ -89,6 +89,7 @@
 #endif
 
 #ifdef IMAP_STORAGE
+AST_MUTEX_DEFINE_STATIC(curhstusr_lock);
 static char *curhst = NIL;	/* currently connected host */
 static char *curusr = NIL;	/* current login user */
 
@@ -4377,8 +4378,6 @@
 	if (res == '1')
 		res = 0;
 
-
-	/* What is the category thing?  JAR */
 	if ((!res) && !ast_strlen_zero(category)) {
 		res = play_message_category(chan, category);
 	}
@@ -7626,7 +7625,6 @@
 				
 				memset(&leave_options, 0, sizeof(leave_options));
 				leave_options.record_gain = record_gain;
-				/* Changed to mailbox instead of num - JAR */
 				res = leave_voicemail(chan, mailbox, &leave_options);
 				if (!res)
 					res = 't';
@@ -7870,10 +7868,9 @@
 		stream = vms->mailstream;
 		/* return 0; */
 	}
-	
+	ast_mutex_lock(&curhstusr_lock);
 	curusr = cpystr (vms->imapuser);
 	curhst = cpystr (mylocalhost ());
-	
 	/* debug = T;  user wants protocol telemetry? */
 	debug = NIL;  /* NO protocol telemetry? */
 	if (strlen(authuser) > 0) {
@@ -7883,6 +7880,7 @@
 	}
 	if(option_debug > 2)
 		ast_log (LOG_DEBUG,"Before mail_open, curusr: %s, mbox:%s\n",curusr,mbox);
+	ast_mutex_unlock(&curhstusr_lock);
 	vms->mailstream = mail_open (stream, mbox, debug ? OP_DEBUG : NIL);
 	if (vms->mailstream == NIL) {
 		return -1;
@@ -8207,6 +8205,7 @@
 	char tmp[MAILTMPLEN];
 	if(option_debug > 3)
 		ast_log(LOG_DEBUG, "Entering callback mm_login\n");
+	ast_mutex_lock(&curhstusr_lock);
 	if (curhst)
 		fs_give ((void **) &curhst);
 	curhst = (char *) fs_get (1 + strlen (mb->host));
@@ -8220,7 +8219,7 @@
 	}
 	if (curusr)
 		fs_give ((void **) &curusr);
-	
+	ast_mutex_unlock(&curhstusr_lock);
 	/* strcpy (pwd, getpass (tmp));*/
 	/* We should only do this when necessary */
 	if (strlen(authpassword) > 0) {
@@ -8408,7 +8407,6 @@
 				ast_log(LOG_DEBUG, "Duplicate mailbox %s, copying message info...\n",vms->username);
 			vms->newmessages = altvms->newmessages;
 			vms->oldmessages = altvms->oldmessages;
-			/* JAR - START HERE - this copy may not be right */
 			if(option_debug > 2)
 				ast_log(LOG_DEBUG, "check_msgArray before memcpy\n");
 			check_msgArray(vms);



More information about the asterisk-commits mailing list