[Asterisk-cvs] asterisk/apps app_voicemail2.c,1.52,1.53

markster at lists.digium.com markster at lists.digium.com
Thu Sep 25 08:16:52 CDT 2003


Update of /usr/cvsroot/asterisk/apps
In directory mongoose.digium.com:/tmp/cvs-serv30822/apps

Modified Files:
	app_voicemail2.c 
Log Message:
Keep voicemail from segging on a permissions problem (bug #245)


Index: app_voicemail2.c
===================================================================
RCS file: /usr/cvsroot/asterisk/apps/app_voicemail2.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -d -r1.52 -r1.53
--- app_voicemail2.c	21 Sep 2003 15:23:54 -0000	1.52
+++ app_voicemail2.c	25 Sep 2003 13:18:03 -0000	1.53
@@ -375,10 +375,24 @@
 		char tmpin[AST_CONFIG_MAX_PATH];
 		char tmpout[AST_CONFIG_MAX_PATH];
 		char *user, *pass, *rest, *trim;
-	snprintf((char *)tmpin, sizeof(tmpin)-1, "%s/voicemail.conf",(char *)ast_config_AST_CONFIG_DIR);
-	snprintf((char *)tmpout, sizeof(tmpout)-1, "%s/voicemail.conf.new",(char *)ast_config_AST_CONFIG_DIR);
+		snprintf((char *)tmpin, sizeof(tmpin)-1, "%s/voicemail.conf",(char *)ast_config_AST_CONFIG_DIR);
+		snprintf((char *)tmpout, sizeof(tmpout)-1, "%s/voicemail.conf.new",(char *)ast_config_AST_CONFIG_DIR);
         configin = fopen((char *)tmpin,"r");
-        configout = fopen((char *)tmpout,"w+");
+		if (configin)
+	        configout = fopen((char *)tmpout,"w+");
+		else
+			configout = NULL;
+		if(!configin || !configout) {
+			if (configin)
+				fclose(configin);
+			else
+				ast_log(LOG_WARNING, "Warning: Unable to open '%s' for reading: %s\n", tmpin, strerror(errno));
+			if (configout)
+				fclose(configout);
+			else
+				ast_log(LOG_WARNING, "Warning: Unable to open '%s' for writing: %s\n", tmpout, strerror(errno));
+			return;
+		}
 
         while (!feof(configin)) {
 			/* Read in the line */
@@ -1955,7 +1969,7 @@
 	/* Can't think of how other diffs might be helpful, but I'm sure somebody will think of something. */
 #endif
 	if (the_zone)
-		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, the_zone->msg_format, &(the_zone->timezone));
+		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, the_zone->msg_format, the_zone->timezone);
 	else
 		res = ast_say_date_with_format(chan, t, AST_DIGIT_ANY, chan->language, "'vm-received' q 'digits/at' IMp", NULL);
 #if 0




More information about the svn-commits mailing list