[asterisk-commits] tilghman: branch 1.4 r68595 - /branches/1.4/pbx/pbx_config.c

asterisk-commits at lists.digium.com asterisk-commits at lists.digium.com
Sun Jun 10 21:21:31 MST 2007


Author: tilghman
Date: Sun Jun 10 23:21:30 2007
New Revision: 68595

URL: http://svn.digium.com/view/asterisk?view=rev&rev=68595
Log:
"dialplan save" produced garbage in the config file

Modified:
    branches/1.4/pbx/pbx_config.c

Modified: branches/1.4/pbx/pbx_config.c
URL: http://svn.digium.com/view/asterisk/branches/1.4/pbx/pbx_config.c?view=diff&rev=68595&r1=68594&r2=68595
==============================================================================
--- branches/1.4/pbx/pbx_config.c (original)
+++ branches/1.4/pbx/pbx_config.c Sun Jun 10 23:21:30 2007
@@ -1320,16 +1320,27 @@
 						    ast_get_extension_app(p));
 				} else { /* copy and replace '|' with ',' */
 					const char *sep, *cid;
-					char *tempdata;
+					char *tempdata = "";
 					char *s;
 					const char *el = ast_get_extension_label(p);
-					char label[128];
+					char label[128] = "";
  
- 					tempdata = ast_strdupa(ast_get_extension_app_data(p));
-
-					for (s = tempdata; *s; s++) {
-						if (*s == '|')
-							*s = ',';
+ 					s = ast_get_extension_app_data(p);
+					if (s) {
+						char *t;
+						tempdata = alloca(strlen(tempdata) * 2 + 1);
+
+						for (t = tempdata; *s; s++, t++) {
+							if (*s == '|')
+								*t = ',';
+							else {
+								if (*s == ',')
+									*t++ = '\\';
+								*t = *s;
+							}
+						}
+						/* Terminating NULL */
+						*t = *s;
 					}
 
 					if (ast_get_extension_matchcid(p)) {
@@ -1338,7 +1349,7 @@
 					} else
 						sep = cid = "";
 				
-					if (el && (snprintf(label, 127, "(%s)", el) != (strlen(el) + 2)))
+					if (el && (snprintf(label, sizeof(label), "(%s)", el) != (strlen(el) + 2)))
 						incomplete = 1;	/* error encountered or label > 125 chars */
 					
 					fprintf(output, "exten => %s%s%s,%d%s,%s(%s)\n",



More information about the asterisk-commits mailing list