From: Michael L. Young Date: Wed, 18 Sep 2013 01:34:09 +0000 (+0000) Subject: Fix Segfault When Syntax Of A Line Under [applicationmap] Is Invalid X-Git-Tag: 11.6.0-rc1~3^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c37158fe050defd498d7f14a5de89fd2e922aa2;p=thirdparty%2Fasterisk.git 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 ........ Merged revisions 399304 from http://svn.asterisk.org/svn/asterisk/branches/1.8 git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@399305 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- diff --git a/main/features.c b/main/features.c index 0a3a24bd64..8789e42952 100644 --- a/main/features.c +++ b/main/features.c @@ -6136,19 +6136,9 @@ static void process_applicationmap_line(struct ast_variable *var) ); 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) @@ -6159,6 +6149,16 @@ static void process_applicationmap_line(struct ast_variable *var) 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);