[asterisk-commits] mnicholson: trunk r231616 - in /trunk: ./ apps/ include/asterisk/ main/

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Mon Nov 30 15:13:47 CST 2009


Author: mnicholson
Date: Mon Nov 30 15:13:42 2009
New Revision: 231616

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=231616
Log:
Merged revisions 231614 via svnmerge from 
https://origsvn.digium.com/svn/asterisk/branches/1.4

........
  r231614 | mnicholson | 2009-11-30 15:11:44 -0600 (Mon, 30 Nov 2009) | 8 lines
  
  Remove duplicate entries from voicemail format lists. This prevents app_voicemail from entering an infinite loop when the same format is specified twice in the format list.
  
  (closes issue #15625)
  Reported by: Shagg63
  Tested by: mnicholson
  
  Review: https://reviewboard.asterisk.org/r/429/
........

Modified:
    trunk/   (props changed)
    trunk/apps/app_voicemail.c
    trunk/include/asterisk/file.h
    trunk/main/app.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-1.4-merged' - no diff available.

Modified: trunk/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/trunk/apps/app_voicemail.c?view=diff&rev=231616&r1=231615&r2=231616
==============================================================================
--- trunk/apps/app_voicemail.c (original)
+++ trunk/apps/app_voicemail.c Mon Nov 30 15:13:42 2009
@@ -10617,7 +10617,7 @@
 	char *cat;
 	struct ast_variable *var;
 	const char *val;
-	char *q, *stringp;
+	char *q, *stringp, *tmp;
 	int x;
 	int tmpadsi[4];
 	struct ast_flags config_flags = { reload ? CONFIG_FLAG_FILEUNCHANGED : 0 };
@@ -10926,8 +10926,16 @@
 		}
 
 		val = ast_variable_retrieve(cfg, "general", "format");
-		if (!val)
+		if (!val) {
 			val = "wav";	
+		} else {
+			tmp = ast_strdupa(val);
+			val = ast_format_str_reduce(tmp);
+			if (!val) {
+				ast_log(LOG_ERROR, "Error processing format string, defaulting to format 'wav'\n");
+				val = "wav";
+			}
+		}
 		ast_copy_string(vmfmts, val, sizeof(vmfmts));
 
 		skipms = 3000;

Modified: trunk/include/asterisk/file.h
URL: http://svnview.digium.com/svn/asterisk/trunk/include/asterisk/file.h?view=diff&rev=231616&r1=231615&r2=231616
==============================================================================
--- trunk/include/asterisk/file.h (original)
+++ trunk/include/asterisk/file.h Mon Nov 30 15:13:42 2009
@@ -39,6 +39,9 @@
 
 struct ast_filestream;
 struct ast_format;
+
+/*! The maximum number of formats we expect to see in a format string */
+#define AST_MAX_FORMATS 10
 
 /*! Convenient for waiting */
 #define AST_DIGIT_ANY "0123456789#*ABCD"
@@ -325,6 +328,14 @@
 
 #define AST_RESERVED_POINTERS 20
 
+/*! Remove duplicate formats from a format string. */
+/*!
+ * \param fmts a format string, this string will be modified
+ * \retval NULL error
+ * \return a pointer to the reduced format string, this is a pointer to fmts
+ */
+char *ast_format_str_reduce(char *fmts);
+
 #if defined(__cplusplus) || defined(c_plusplus)
 }
 #endif

Modified: trunk/main/app.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/app.c?view=diff&rev=231616&r1=231615&r2=231616
==============================================================================
--- trunk/main/app.c (original)
+++ trunk/main/app.c Mon Nov 30 15:13:42 2009
@@ -55,7 +55,7 @@
 AST_THREADSTORAGE_PUBLIC(ast_str_thread_global_buf);
 
 
-#define MAX_OTHER_FORMATS 10
+#define AST_MAX_FORMATS 10
 
 static AST_RWLIST_HEAD_STATIC(groups, ast_group_info);
 
@@ -693,8 +693,8 @@
 	char *fmts;
 	char comment[256];
 	int x, fmtcnt = 1, res = -1, outmsg = 0;
-	struct ast_filestream *others[MAX_OTHER_FORMATS];
-	char *sfmt[MAX_OTHER_FORMATS];
+	struct ast_filestream *others[AST_MAX_FORMATS];
+	char *sfmt[AST_MAX_FORMATS];
 	char *stringp = NULL;
 	time_t start, end;
 	struct ast_dsp *sildet = NULL;   /* silence detector dsp */
@@ -747,8 +747,8 @@
 	sfmt[0] = ast_strdupa(fmts);
 
 	while ((fmt = strsep(&stringp, "|"))) {
-		if (fmtcnt > MAX_OTHER_FORMATS - 1) {
-			ast_log(LOG_WARNING, "Please increase MAX_OTHER_FORMATS in app.c\n");
+		if (fmtcnt > AST_MAX_FORMATS - 1) {
+			ast_log(LOG_WARNING, "Please increase AST_MAX_FORMATS in file.h\n");
 			break;
 		}
 		sfmt[fmtcnt++] = ast_strdupa(fmt);
@@ -938,7 +938,7 @@
 	}
 
 	if (prepend && outmsg) {
-		struct ast_filestream *realfiles[MAX_OTHER_FORMATS];
+		struct ast_filestream *realfiles[AST_MAX_FORMATS];
 		struct ast_frame *fr;
 
 		for (x = 0; x < fmtcnt; x++) {




More information about the asterisk-commits mailing list