Catch invalid extensions at the parser, instead of making the core deal with them.

(closes issue #17794)
 Reported by: PavelL
 Patches: 
       20100820__issue17794__1.6.2.diff.txt uploaded by tilghman (license 14)
       20100820__issue17794__1.4.diff.txt uploaded by tilghman (license 14)
 Tested by: PavelL


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@285365 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2010-09-07 20:30:22 +00:00
parent a91eaba875
commit 3d70384b2f

View File

@@ -2211,8 +2211,11 @@ static int pbx_load_config(const char *config_file)
char *pri, *appl, *data, *cidmatch; char *pri, *appl, *data, *cidmatch;
char *stringp = tc; char *stringp = tc;
char *ext = strsep(&stringp, ","); char *ext = strsep(&stringp, ",");
if (!ext) if (!ext) {
ext=""; ast_log(LOG_WARNING, "Bogus extension at line %d\n", v->lineno);
ast_free(tc);
continue;
}
pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1); pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1);
cidmatch = strchr(realext, '/'); cidmatch = strchr(realext, '/');
if (cidmatch) { if (cidmatch) {
@@ -2220,8 +2223,11 @@ static int pbx_load_config(const char *config_file)
ast_shrink_phone_number(cidmatch); ast_shrink_phone_number(cidmatch);
} }
pri = strsep(&stringp, ","); pri = strsep(&stringp, ",");
if (!pri) if (!pri) {
pri=""; ast_log(LOG_WARNING, "Bogus extension at line %d\n", v->lineno);
ast_free(tc);
continue;
}
pri = ast_skip_blanks(pri); pri = ast_skip_blanks(pri);
pri = ast_trim_blanks(pri); pri = ast_trim_blanks(pri);
label = strchr(pri, '('); label = strchr(pri, '(');
@@ -2234,26 +2240,39 @@ static int pbx_load_config(const char *config_file)
ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno); ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno);
} }
plus = strchr(pri, '+'); plus = strchr(pri, '+');
if (plus) if (plus) {
*plus++ = '\0'; *plus++ = '\0';
if (!strcmp(pri,"hint")) }
ipri=PRIORITY_HINT; if (!strcmp(pri, "hint")) {
else if (!strcmp(pri, "next") || !strcmp(pri, "n")) { ipri = PRIORITY_HINT;
if (lastpri > -2) } else if (!strcmp(pri, "next") || !strcmp(pri, "n")) {
if (lastpri > -2) {
ipri = lastpri + 1; ipri = lastpri + 1;
else } else {
ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry!\n"); ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry at line %d!\n", v->lineno);
ast_free(tc);
continue;
}
} else if (!strcmp(pri, "same") || !strcmp(pri, "s")) { } else if (!strcmp(pri, "same") || !strcmp(pri, "s")) {
if (lastpri > -2) if (lastpri > -2) {
ipri = lastpri; ipri = lastpri;
else } else {
ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry!\n"); ast_log(LOG_WARNING, "Can't use 'same' priority on the first entry at line %d!\n", v->lineno);
ast_free(tc);
continue;
}
} else if (sscanf(pri, "%30d", &ipri) != 1 && } else if (sscanf(pri, "%30d", &ipri) != 1 &&
(ipri = ast_findlabel_extension2(NULL, con, realext, pri, cidmatch)) < 1) { (ipri = ast_findlabel_extension2(NULL, con, realext, pri, cidmatch)) < 1) {
ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno); ast_log(LOG_WARNING, "Invalid priority/label '%s' at line %d\n", pri, v->lineno);
ipri = 0; ipri = 0;
ast_free(tc);
continue;
}
if (ast_strlen_zero(appl = S_OR(stringp, ""))) {
ast_log(LOG_WARNING, "Bogus extension at line %d\n", v->lineno);
ast_free(tc);
continue;
} }
appl = S_OR(stringp, "");
/* Find the first occurrence of either '(' or ',' */ /* Find the first occurrence of either '(' or ',' */
firstc = strchr(appl, ','); firstc = strchr(appl, ',');
firstp = strchr(appl, '('); firstp = strchr(appl, '(');