aboutsummaryrefslogtreecommitdiffstats
path: root/pbx
diff options
context:
space:
mode:
authortilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-11 04:21:30 +0000
committertilghman <tilghman@f38db490-d61c-443f-a65b-d21fe96a405b>2007-06-11 04:21:30 +0000
commit0f0446f2dd6e944f71c8ba725e00e2354e16191b (patch)
tree91945a357bc9bbac82c9c7c80332d35991bc8973 /pbx
parent106d72f008e511a06fdb39c8e467238c77270db8 (diff)
"dialplan save" produced garbage in the config file
git-svn-id: http://svn.digium.com/svn/asterisk/branches/1.4@68595 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_config.c27
1 files changed, 19 insertions, 8 deletions
diff --git a/pbx/pbx_config.c b/pbx/pbx_config.c
index 0546bad88..a844cfc2b 100644
--- a/pbx/pbx_config.c
+++ b/pbx/pbx_config.c
@@ -1320,16 +1320,27 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
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 @@ static int handle_save_dialplan(int fd, int argc, char *argv[])
} 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",