properly detect unterminated
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13438 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c8d0cea3f2
commit
531e0f2d15
|
@ -261,7 +261,7 @@ SWITCH_DECLARE(char *) switch_find_end_paren(const char *s, char open, char clos
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
SWITCH_DECLARE(switch_size_t) switch_fd_read_line(int fd, char *buf, switch_size_t len)
|
||||||
|
|
|
@ -1132,7 +1132,7 @@ SWITCH_DECLARE(switch_xml_t) switch_xml_parse_fd(int fd)
|
||||||
return &root->xml;
|
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 *var, *val;
|
||||||
char *rp = buf;
|
char *rp = buf;
|
||||||
|
@ -1161,6 +1161,8 @@ static char *expand_vars(char *buf, char *ebuf, switch_size_t elen, switch_size_
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
|
} else if (err) {
|
||||||
|
*err = "unterminated ${var}";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1267,6 +1269,7 @@ static int preprocess(const char *cwd, const char *file, int write_fd, int rleve
|
||||||
switch_size_t cur = 0, ml = 0;
|
switch_size_t cur = 0, ml = 0;
|
||||||
char *q, *cmd, buf[2048], ebuf[8192];
|
char *q, *cmd, buf[2048], ebuf[8192];
|
||||||
char *tcmd, *targ;
|
char *tcmd, *targ;
|
||||||
|
int line = 0;
|
||||||
|
|
||||||
if ((read_fd = open(file, O_RDONLY, 0)) < 0) {
|
if ((read_fd = open(file, O_RDONLY, 0)) < 0) {
|
||||||
const char *reason = strerror(errno);
|
const char *reason = strerror(errno);
|
||||||
|
@ -1280,7 +1283,13 @@ static int preprocess(const char *cwd, const char *file, int write_fd, int rleve
|
||||||
|
|
||||||
while ((cur = switch_fd_read_line(read_fd, buf, sizeof(buf))) > 0) {
|
while ((cur = switch_fd_read_line(read_fd, buf, sizeof(buf))) > 0) {
|
||||||
char *arg, *e;
|
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 */
|
/* 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, "<?")) {
|
if (strstr(buf, "<include>") || strstr(buf, "</include>") || strstr(buf, "<?")) {
|
||||||
|
|
Loading…
Reference in New Issue