[asterisk-commits] tilghman: branch 1.6.2 r285366 - in /branches/1.6.2: ./ pbx/pbx_config.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 7 15:31:46 CDT 2010


Author: tilghman
Date: Tue Sep  7 15:31:41 2010
New Revision: 285366

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=285366
Log:
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
........

Modified:
    branches/1.6.2/   (props changed)
    branches/1.6.2/pbx/pbx_config.c

Propchange: branches/1.6.2/
------------------------------------------------------------------------------
--- branch-1.4-merged (original)
+++ branch-1.4-merged Tue Sep  7 15:31:41 2010
@@ -1,1 +1,1 @@
-/branches/1.4:1-279056,279206,279945,280088,280341,280448,280811,280982,281390,281566,281762,281819,281911,282129,282430,282729,282893,283048,283123,283380,283690,283880,283960,284316,284393,284478,284703,284777,284881,285088,285194,285266
+/branches/1.4:1-279056,279206,279945,280088,280341,280448,280811,280982,281390,281566,281762,281819,281911,282129,282430,282729,282893,283048,283123,283380,283690,283880,283960,284316,284393,284478,284703,284777,284881,285088,285194,285266,285365

Modified: branches/1.6.2/pbx/pbx_config.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.6.2/pbx/pbx_config.c?view=diff&rev=285366&r1=285365&r2=285366
==============================================================================
--- branches/1.6.2/pbx/pbx_config.c (original)
+++ branches/1.6.2/pbx/pbx_config.c Tue Sep  7 15:31:41 2010
@@ -1457,15 +1457,15 @@
 					*cidmatch++ = '\0';
 					ast_shrink_phone_number(cidmatch);
 				}
-				pri = S_OR(strsep(&stringp, ","), "");
-				pri = ast_skip_blanks(pri);
-				pri = ast_trim_blanks(pri);
+				pri = ast_strip(S_OR(strsep(&stringp, ","), ""));
 				if ((label = strchr(pri, '('))) {
 					*label++ = '\0';
 					if ((end = strchr(label, ')'))) {
 						*end = '\0';
 					} else {
 						ast_log(LOG_WARNING, "Label missing trailing ')' at line %d\n", v->lineno);
+						ast_free(tc);
+						continue;
 					}
 				}
 				if ((plus = strchr(pri, '+'))) {
@@ -1478,17 +1478,27 @@
 						ipri = lastpri + 1;
 					} else {
 						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")) {
 					if (lastpri > -2) {
 						ipri = lastpri;
 					} else {
 						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 &&
 					   (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);
 					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, "");
 				/* Find the first occurrence of '(' */
@@ -1498,9 +1508,11 @@
 				} else {
 					char *orig_appl = ast_strdup(appl);
 
-					if (!orig_appl)
-						return -1;
-					
+					if (!orig_appl) {
+						ast_free(tc);
+						continue;
+					}
+
 					appl = strsep(&stringp, "(");
 
 					/* check if there are variables or expressions without an application, like: exten => 100,hint,DAHDI/g0/${GLOBAL(var)}  */
@@ -1527,8 +1539,8 @@
 						ipri += atoi(plus);
 					}
 					lastpri = ipri;
-					if (!ast_opt_dont_warn && !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);
+					if (!ast_opt_dont_warn && (!strcmp(realext, "_.") || !strcmp(realext, "_!"))) {
+						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)) {
 						ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);




More information about the asterisk-commits mailing list