Merged revisions 285367 via svnmerge from

https://origsvn.digium.com/svn/asterisk/branches/1.8

................
  r285367 | tilghman | 2010-09-07 15:56:07 -0500 (Tue, 07 Sep 2010) | 23 lines
  
  Merged revisions 285366 via svnmerge from 
  https://origsvn.digium.com/svn/asterisk/branches/1.6.2
  
  ................
    r285366 | tilghman | 2010-09-07 15:31:41 -0500 (Tue, 07 Sep 2010) | 16 lines
    
    Merged revisions 285365 via svnmerge from 
    https://origsvn.digium.com/svn/asterisk/branches/1.4
    
    ........
      r285365 | tilghman | 2010-09-07 15:30:22 -0500 (Tue, 07 Sep 2010) | 9 lines
      
      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/trunk@285368 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Tilghman Lesher
2010-09-07 20:56:53 +00:00
parent 875561fc2f
commit 90bf5c0549

View File

@@ -1456,15 +1456,15 @@ process_extension:
*cidmatch++ = '\0'; *cidmatch++ = '\0';
ast_shrink_phone_number(cidmatch); ast_shrink_phone_number(cidmatch);
} }
pri = S_OR(strsep(&stringp, ","), ""); pri = ast_strip(S_OR(strsep(&stringp, ","), ""));
pri = ast_skip_blanks(pri);
pri = ast_trim_blanks(pri);
if ((label = strchr(pri, '('))) { if ((label = strchr(pri, '('))) {
*label++ = '\0'; *label++ = '\0';
if ((end = strchr(label, ')'))) { if ((end = strchr(label, ')'))) {
*end = '\0'; *end = '\0';
} else { } else {
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);
ast_free(tc);
continue;
} }
} }
if ((plus = strchr(pri, '+'))) { if ((plus = strchr(pri, '+'))) {
@@ -1477,17 +1477,27 @@ process_extension:
ipri = lastpri + 1; ipri = lastpri + 1;
} else { } else {
ast_log(LOG_WARNING, "Can't use 'next' priority on the first entry at line %d!\n", v->lineno); 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 at line %d!\n", v->lineno); 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;
} else if (ipri < 1) {
ast_log(LOG_WARNING, "Invalid priority '%s' at line %d\n", pri, v->lineno);
ast_free(tc);
continue;
} }
appl = S_OR(stringp, ""); appl = S_OR(stringp, "");
/* Find the first occurrence of '(' */ /* Find the first occurrence of '(' */
@@ -1497,8 +1507,10 @@ process_extension:
} else { } else {
char *orig_appl = ast_strdup(appl); char *orig_appl = ast_strdup(appl);
if (!orig_appl) if (!orig_appl) {
return -1; ast_free(tc);
continue;
}
appl = strsep(&stringp, "("); appl = strsep(&stringp, "(");
@@ -1526,8 +1538,8 @@ process_extension:
ipri += atoi(plus); ipri += atoi(plus);
} }
lastpri = ipri; lastpri = ipri;
if (!ast_opt_dont_warn && !strcmp(realext, "_.")) { if (!ast_opt_dont_warn && (!strcmp(realext, "_.") || !strcmp(realext, "_!"))) {
ast_log(LOG_WARNING, "The use of '_.' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X.' instead at line %d\n", v->lineno); ast_log(LOG_WARNING, "The use of '%s' for an extension is strongly discouraged and can have unexpected behavior. Please use '_X%c' instead at line %d\n", realext, realext[1], v->lineno);
} }
if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free_ptr, registrar)) { if (ast_add_extension2(con, 0, realext, ipri, label, cidmatch, appl, strdup(data), ast_free_ptr, registrar)) {
ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno); ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);