[asterisk-commits] elguero: branch 1.8 r399304 - /branches/1.8/main/features.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Tue Sep 17 20:32:42 CDT 2013


Author: elguero
Date: Tue Sep 17 20:32:36 2013
New Revision: 399304

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=399304
Log:
Fix Segfault When Syntax Of A Line Under [applicationmap] Is Invalid

When processing the lines under the [applicationmap] context in features.conf, a
segfault occurs from attempting to process a line with an invalid syntax
(basically missing most of the arguments).

Example:
[applicationmap]
automon=*6

* This patch moves the checking for empty arguments to before they are accessed.

* Also, checked the "todo" comment and removed it.  Some applications do not
  require arguments.

(closes issue ASTERISK-22416)
Reported by: CGI.NET
Tested by: CGI.NET
Patches:
    asterisk-22416-check-syntax-first_v2.diff by Michael L. Young (license 5026)

Review: https://reviewboard.asterisk.org/r/2803

Modified:
    branches/1.8/main/features.c

Modified: branches/1.8/main/features.c
URL: http://svnview.digium.com/svn/asterisk/branches/1.8/main/features.c?view=diff&rev=399304&r1=399303&r2=399304
==============================================================================
--- branches/1.8/main/features.c (original)
+++ branches/1.8/main/features.c Tue Sep 17 20:32:36 2013
@@ -5733,19 +5733,9 @@
 	);
 
 	AST_STANDARD_APP_ARGS(args, tmp_val);
-	if ((new_syn = strchr(args.app, '('))) {
-		/* New syntax */
-		args.moh_class = args.app_args;
-		args.app_args = new_syn;
-		*args.app_args++ = '\0';
-		if (args.app_args[strlen(args.app_args) - 1] == ')') {
-			args.app_args[strlen(args.app_args) - 1] = '\0';
-		}
-	}
 
 	activateon = strsep(&args.activatedby, "/");
 
-	/*! \todo XXX var_name or app_args ? */
 	if (ast_strlen_zero(args.app)
 		|| ast_strlen_zero(args.exten)
 		|| ast_strlen_zero(activateon)
@@ -5756,6 +5746,16 @@
 		return;
 	}
 
+	if ((new_syn = strchr(args.app, '('))) {
+		/* New syntax */
+		args.moh_class = args.app_args;
+		args.app_args = new_syn;
+		*args.app_args++ = '\0';
+		if (args.app_args[strlen(args.app_args) - 1] == ')') {
+			args.app_args[strlen(args.app_args) - 1] = '\0';
+		}
+	}
+	
 	AST_RWLIST_RDLOCK(&feature_list);
 	if (find_dynamic_feature(var->name)) {
 		AST_RWLIST_UNLOCK(&feature_list);




More information about the asterisk-commits mailing list