[Asterisk-cvs] asterisk/pbx pbx_config.c,1.27,1.28

markster at lists.digium.com markster at lists.digium.com
Sun Nov 23 16:14:16 CST 2003


Update of /usr/cvsroot/asterisk/pbx
In directory mongoose.digium.com:/tmp/cvs-serv24967/pbx

Modified Files:
	pbx_config.c 
Log Message:
Be less picky about spaces, and recognize invalid priorities


Index: pbx_config.c
===================================================================
RCS file: /usr/cvsroot/asterisk/pbx/pbx_config.c,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- pbx_config.c	17 Nov 2003 23:53:22 -0000	1.27
+++ pbx_config.c	23 Nov 2003 22:40:37 -0000	1.28
@@ -1116,10 +1116,13 @@
 	}
 	prior       = strsep(&whole_exten,",");
 	if (prior) {
-    		if (!strcmp(prior, "hint")) {
+    	if (!strcmp(prior, "hint")) {
 			iprior = PRIORITY_HINT;
 		} else {
-			iprior = atoi(prior);
+			if (scanf(prior, "%i", &iprior) != 1) {
+				ast_cli(fd, "'%s' is not a valid priority\n", prior);
+				prior = NULL;
+			}
 		}
 	}
 	app         = strsep(&whole_exten,",");
@@ -1579,8 +1582,12 @@
 								pri="";
 							if (!strcmp(pri,"hint"))
 								ipri=PRIORITY_HINT;
-							else
-								ipri=atoi(pri);
+							else {
+								if (sscanf(pri, "%i", &ipri) != 1) {
+									ast_log(LOG_WARNING, "Invalid priority '%s' at line %d\n", pri, v->lineno);
+									ipri = 0;
+								}
+							}
 							appl = stringp;
 							if (!appl)
 								appl="";
@@ -1617,8 +1624,10 @@
 							if (!data)
 								data="";
 							pbx_substitute_variables_helper(NULL, ext, realext, sizeof(realext) - 1);
-							if (ast_add_extension2(con, 0, realext, ipri, cidmatch, appl, strdup(data), FREE, registrar)) {
-								ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
+							if (ipri) {
+								if (ast_add_extension2(con, 0, realext, ipri, cidmatch, appl, strdup(data), FREE, registrar)) {
+									ast_log(LOG_WARNING, "Unable to register extension at line %d\n", v->lineno);
+								}
 							}
 							free(tc);
 						} else fprintf(stderr,"Error strdup returned NULL in %s\n",__PRETTY_FUNCTION__);




More information about the svn-commits mailing list