[Freeswitch-svn] [commit] r13438 - freeswitch/trunk/src
FreeSWITCH SVN
anthm at freeswitch.org
Tue May 26 11:04:22 PDT 2009
Author: anthm
Date: Tue May 26 13:04:22 2009
New Revision: 13438
Log:
properly detect unterminated
Modified:
freeswitch/trunk/src/switch_utils.c
freeswitch/trunk/src/switch_xml.c
Modified: freeswitch/trunk/src/switch_utils.c
==============================================================================
--- freeswitch/trunk/src/switch_utils.c (original)
+++ freeswitch/trunk/src/switch_utils.c Tue May 26 13:04:22 2009
@@ -261,7 +261,7 @@
}
}
- return (char *) e;
+ return (e && *e == close) ? (char *) e : NULL;
}
SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size_t len)
Modified: freeswitch/trunk/src/switch_xml.c
==============================================================================
--- freeswitch/trunk/src/switch_xml.c (original)
+++ freeswitch/trunk/src/switch_xml.c Tue May 26 13:04:22 2009
@@ -1132,7 +1132,7 @@
return &root->xml;
}
-static char *expand_vars(char *buf, char *ebuf, switch_size_t elen, switch_size_t *newlen)
+static char *expand_vars(char *buf, char *ebuf, switch_size_t elen, switch_size_t *newlen, const char **err)
{
char *var, *val;
char *rp = buf;
@@ -1161,6 +1161,8 @@
}
}
continue;
+ } else if (err) {
+ *err = "unterminated ${var}";
}
}
@@ -1267,7 +1269,8 @@
switch_size_t cur = 0, ml = 0;
char *q, *cmd, buf[2048], ebuf[8192];
char *tcmd, *targ;
-
+ int line = 0;
+
if ((read_fd = open(file, O_RDONLY, 0)) < 0) {
const char *reason = strerror(errno);
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Couldnt open %s (%s)\n", file, reason);
@@ -1280,7 +1283,13 @@
while ((cur = switch_fd_read_line(read_fd, buf, sizeof(buf))) > 0) {
char *arg, *e;
- char *bp = expand_vars(buf, ebuf, sizeof(ebuf), &cur);
+ const char *err = NULL;
+ char *bp = expand_vars(buf, ebuf, sizeof(ebuf), &cur, &err);
+ line++;
+
+ if (err && stderr) {
+ fprintf(stderr, "Error [%s] in line %s line %d\n", err, file, line);
+ }
/* we ignore <include> or </include> for the sake of validators as well as <?xml version="1.0"?> type stuff */
if (strstr(buf, "<include>") || strstr(buf, "</include>") || strstr(buf, "<?")) {
More information about the Freeswitch-svn
mailing list