[asterisk-commits] coreyfarrell: branch 12 r411315 - in /branches/12: ./ apps/ apps/confbridge/ ...

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Thu Mar 27 14:15:47 CDT 2014


Author: coreyfarrell
Date: Thu Mar 27 14:15:35 2014
New Revision: 411315

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411315
Log:
Fix dialplan function NULL channel safety issues

(closes issue ASTERISK-23391)
Reported by: Corey Farrell
Review: https://reviewboard.asterisk.org/r/3386/
........

Merged revisions 411313 from http://svn.asterisk.org/svn/asterisk/branches/1.8
........

Merged revisions 411314 from http://svn.asterisk.org/svn/asterisk/branches/11

Modified:
    branches/12/   (props changed)
    branches/12/apps/app_jack.c
    branches/12/apps/app_speech_utils.c
    branches/12/apps/app_stack.c
    branches/12/apps/app_voicemail.c
    branches/12/apps/confbridge/conf_config_parser.c
    branches/12/channels/chan_iax2.c
    branches/12/channels/chan_sip.c
    branches/12/channels/pjsip/dialplan_functions.c
    branches/12/funcs/func_blacklist.c
    branches/12/funcs/func_callcompletion.c
    branches/12/funcs/func_callerid.c
    branches/12/funcs/func_cdr.c
    branches/12/funcs/func_channel.c
    branches/12/funcs/func_dialplan.c
    branches/12/funcs/func_frame_trace.c
    branches/12/funcs/func_global.c
    branches/12/funcs/func_groupcount.c
    branches/12/funcs/func_jitterbuffer.c
    branches/12/funcs/func_math.c
    branches/12/funcs/func_odbc.c
    branches/12/funcs/func_pitchshift.c
    branches/12/funcs/func_speex.c
    branches/12/funcs/func_strings.c
    branches/12/funcs/func_volume.c
    branches/12/main/features_config.c
    branches/12/main/message.c
    branches/12/res/res_calendar.c
    branches/12/res/res_jabber.c
    branches/12/res/res_mutestream.c
    branches/12/res/res_pjsip_header_funcs.c
    branches/12/res/res_xmpp.c

Propchange: branches/12/
------------------------------------------------------------------------------
Binary property 'branch-11-merged' - no diff available.

Modified: branches/12/apps/app_jack.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_jack.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/apps/app_jack.c (original)
+++ branches/12/apps/app_jack.c Thu Mar 27 14:15:35 2014
@@ -951,6 +951,11 @@
 {
 	int res;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (!strcasecmp(value, "on"))
 		res = enable_jack_hook(chan, data);
 	else if (!strcasecmp(value, "off"))

Modified: branches/12/apps/app_speech_utils.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_speech_utils.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/apps/app_speech_utils.c (original)
+++ branches/12/apps/app_speech_utils.c Thu Mar 27 14:15:35 2014
@@ -285,7 +285,11 @@
 {
 	struct ast_speech *speech = NULL;
 	struct ast_datastore *datastore = NULL;
-	
+
+	if (!chan) {
+		return NULL;
+	}
+
 	datastore = ast_channel_datastore_find(chan, &speech_datastore, NULL);
 	if (datastore == NULL) {
 		return NULL;

Modified: branches/12/apps/app_stack.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_stack.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/apps/app_stack.c (original)
+++ branches/12/apps/app_stack.c Thu Mar 27 14:15:35 2014
@@ -708,6 +708,11 @@
 	struct gosub_stack_frame *frame;
 	struct ast_var_t *variables;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	ast_channel_lock(chan);
 	if (!(stack_store = ast_channel_datastore_find(chan, &stack_info, NULL))) {
 		ast_channel_unlock(chan);
@@ -741,6 +746,11 @@
 	struct ast_datastore *stack_store;
 	struct gosub_stack_list *oldlist;
 	struct gosub_stack_frame *frame;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
 
 	ast_channel_lock(chan);
 	if (!(stack_store = ast_channel_datastore_find(chan, &stack_info, NULL))) {

Modified: branches/12/apps/app_voicemail.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/app_voicemail.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/apps/app_voicemail.c (original)
+++ branches/12/apps/app_voicemail.c Thu Mar 27 14:15:35 2014
@@ -12092,7 +12092,9 @@
 		} else if (!strncasecmp(arg.attribute, "pager", 5)) {
 			ast_copy_string(buf, vmu->pager, len);
 		} else if (!strncasecmp(arg.attribute, "language", 8)) {
-			ast_copy_string(buf, S_OR(vmu->language, ast_channel_language(chan)), len);
+			const char *lang = S_OR(vmu->language, chan ?
+				ast_channel_language(chan) : ast_defaultlanguage);
+			ast_copy_string(buf, lang, len);
 		} else if (!strncasecmp(arg.attribute, "locale", 6)) {
 			ast_copy_string(buf, vmu->locale, len);
 		} else if (!strncasecmp(arg.attribute, "tz", 2)) {

Modified: branches/12/apps/confbridge/conf_config_parser.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/apps/confbridge/conf_config_parser.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/apps/confbridge/conf_config_parser.c (original)
+++ branches/12/apps/confbridge/conf_config_parser.c Thu Mar 27 14:15:35 2014
@@ -935,6 +935,11 @@
 		AST_APP_ARG(option);
 	);
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	/* parse all the required arguments and make sure they exist. */
 	if (ast_strlen_zero(data)) {
 		return -1;

Modified: branches/12/channels/chan_iax2.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/channels/chan_iax2.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/channels/chan_iax2.c (original)
+++ branches/12/channels/chan_iax2.c Thu Mar 27 14:15:35 2014
@@ -9872,10 +9872,16 @@
 
 static int acf_iaxvar_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
-	struct ast_datastore *variablestore = ast_channel_datastore_find(chan, &iax2_variable_datastore_info, NULL);
+	struct ast_datastore *variablestore;
 	AST_LIST_HEAD(, ast_var_t) *varlist;
 	struct ast_var_t *var;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	variablestore = ast_channel_datastore_find(chan, &iax2_variable_datastore_info, NULL);
 	if (!variablestore) {
 		*buf = '\0';
 		return 0;
@@ -9895,10 +9901,16 @@
 
 static int acf_iaxvar_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
 {
-	struct ast_datastore *variablestore = ast_channel_datastore_find(chan, &iax2_variable_datastore_info, NULL);
+	struct ast_datastore *variablestore;
 	AST_LIST_HEAD(, ast_var_t) *varlist;
 	struct ast_var_t *var;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	variablestore = ast_channel_datastore_find(chan, &iax2_variable_datastore_info, NULL);
 	if (!variablestore) {
 		variablestore = ast_datastore_alloc(&iax2_variable_datastore_info, NULL);
 		if (!variablestore) {
@@ -14189,8 +14201,9 @@
 	/* if our channel, return the IP address of the endpoint of current channel */
 	if (!strcmp(peername,"CURRENTCHANNEL")) {
 	        unsigned short callno;
-		if (ast_channel_tech(chan) != &iax2_tech)
+		if (!chan || ast_channel_tech(chan) != &iax2_tech) {
 			return -1;
+		}
 		callno = PTR_TO_CALLNO(ast_channel_tech_pvt(chan));
 		ast_copy_string(buf, !ast_sockaddr_isnull(&iaxs[callno]->addr) ? ast_sockaddr_stringify_addr(&iaxs[callno]->addr) : "", len);
 		return 0;

Modified: branches/12/channels/chan_sip.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/channels/chan_sip.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/channels/chan_sip.c (original)
+++ branches/12/channels/chan_sip.c Thu Mar 27 14:15:35 2014
@@ -22450,7 +22450,12 @@
 	);
 	int i, number, start = 0;
 
- 	if (ast_strlen_zero(data)) {
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
+
+	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "This function requires a header name.\n");
 		return -1;
 	}
@@ -22636,7 +22641,12 @@
 
 	*buf = 0;
 
- 	if (!data) {
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	if (!data) {
 		ast_log(LOG_WARNING, "This function requires a parameter name.\n");
 		return -1;
 	}

Modified: branches/12/channels/pjsip/dialplan_functions.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/channels/pjsip/dialplan_functions.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/channels/pjsip/dialplan_functions.c (original)
+++ branches/12/channels/pjsip/dialplan_functions.c Thu Mar 27 14:15:35 2014
@@ -682,7 +682,7 @@
 int pjsip_acf_channel_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
 	struct pjsip_func_args func_args = { 0, };
-	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(chan);
+	struct ast_sip_channel_pvt *channel;
 	char *parse = ast_strdupa(data);
 
 	AST_DECLARE_APP_ARGS(args,
@@ -690,6 +690,12 @@
 		AST_APP_ARG(type);
 		AST_APP_ARG(field);
 	);
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+	channel = ast_channel_tech_pvt(chan);
 
 	/* Check for zero arguments */
 	if (ast_strlen_zero(parse)) {
@@ -863,7 +869,14 @@
 
 int pjsip_acf_media_offer_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
-	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(chan);
+	struct ast_sip_channel_pvt *channel;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	channel = ast_channel_tech_pvt(chan);
 
 	if (!strcmp(data, "audio")) {
 		return media_offer_read_av(channel->session, buf, len, AST_FORMAT_TYPE_AUDIO);
@@ -876,12 +889,18 @@
 
 int pjsip_acf_media_offer_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
 {
-	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(chan);
-
+	struct ast_sip_channel_pvt *channel;
 	struct media_offer_data mdata = {
-		.session = channel->session,
 		.value = value
 	};
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	channel = ast_channel_tech_pvt(chan);
+	mdata.session = channel->session;
 
 	if (!strcmp(data, "audio")) {
 		mdata.media_type = AST_FORMAT_TYPE_AUDIO;

Modified: branches/12/funcs/func_blacklist.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_blacklist.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_blacklist.c (original)
+++ branches/12/funcs/func_blacklist.c Thu Mar 27 14:15:35 2014
@@ -61,6 +61,11 @@
 	char blacklist[1];
 	int bl = 0;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (ast_channel_caller(chan)->id.number.valid && ast_channel_caller(chan)->id.number.str) {
 		if (!ast_db_get("blacklist", ast_channel_caller(chan)->id.number.str, blacklist, sizeof (blacklist)))
 			bl = 1;

Modified: branches/12/funcs/func_callcompletion.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_callcompletion.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_callcompletion.c (original)
+++ branches/12/funcs/func_callcompletion.c Thu Mar 27 14:15:35 2014
@@ -74,6 +74,11 @@
 	struct ast_cc_config_params *cc_params;
 	int res;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", name);
+		return -1;
+	}
+
 	ast_channel_lock(chan);
 	if (!(cc_params = ast_channel_get_cc_config_params(chan))) {
 		ast_channel_unlock(chan);
@@ -90,6 +95,11 @@
 {
 	struct ast_cc_config_params *cc_params;
 	int res;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
 
 	ast_channel_lock(chan);
 	if (!(cc_params = ast_channel_get_cc_config_params(chan))) {

Modified: branches/12/funcs/func_callerid.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_callerid.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_callerid.c (original)
+++ branches/12/funcs/func_callerid.c Thu Mar 27 14:15:35 2014
@@ -900,6 +900,11 @@
  */
 static int callerpres_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len)
 {
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (!callerpres_deprecate_notify) {
 		callerpres_deprecate_notify = 1;
 		ast_log(LOG_WARNING, "CALLERPRES is deprecated."
@@ -925,6 +930,11 @@
 static int callerpres_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
 {
 	int pres;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
 
 	if (!callerpres_deprecate_notify) {
 		callerpres_deprecate_notify = 1;

Modified: branches/12/funcs/func_cdr.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_cdr.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_cdr.c (original)
+++ branches/12/funcs/func_cdr.c Thu Mar 27 14:15:35 2014
@@ -441,6 +441,11 @@
 		ao2_alloc(sizeof(*payload), NULL), ao2_cleanup);
 	struct cdr_func_data output = { 0, };
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (!payload) {
 		return -1;
 	}
@@ -489,6 +494,11 @@
 	RAII_VAR(struct stasis_message_router *, router,
 		     ast_cdr_message_router(), ao2_cleanup);
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (!router) {
 		ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message router\n",
 			ast_channel_name(chan));
@@ -521,6 +531,11 @@
 	RAII_VAR(struct cdr_func_payload *, payload,
 		ao2_alloc(sizeof(*payload), NULL), ao2_cleanup);
 	RAII_VAR(struct stasis_message_router *, router, ast_cdr_message_router(), ao2_cleanup);
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
 
 	if (!router) {
 		ast_log(AST_LOG_WARNING, "Failed to manipulate CDR for channel %s: no message router\n",

Modified: branches/12/funcs/func_channel.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_channel.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_channel.c (original)
+++ branches/12/funcs/func_channel.c Thu Mar 27 14:15:35 2014
@@ -421,6 +421,11 @@
 	int ret = 0;
 	struct ast_format_cap *tmpcap;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
+
 	if (!strcasecmp(data, "audionativeformat")) {
 		char tmp[512];
 
@@ -733,6 +738,11 @@
 		.value = value,
 	};
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
+
 	res = func_channel_write_real(chan, function, data, value);
 	ast_channel_setoption(chan, AST_OPTION_CHANNEL_WRITE, &write_info, sizeof(write_info), 0);
 
@@ -806,8 +816,15 @@
 static int func_mchan_read(struct ast_channel *chan, const char *function,
 			     char *data, struct ast_str **buf, ssize_t len)
 {
-	struct ast_channel *mchan = ast_channel_get_by_name(ast_channel_linkedid(chan));
+	struct ast_channel *mchan;
 	char *template = ast_alloca(4 + strlen(data));
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
+
+	mchan = ast_channel_get_by_name(ast_channel_linkedid(chan));
 	sprintf(template, "${%s}", data); /* SAFE */
 	ast_str_substitute_variables(buf, len, mchan ? mchan : chan, template);
 	if (mchan) {
@@ -819,7 +836,14 @@
 static int func_mchan_write(struct ast_channel *chan, const char *function,
 			      char *data, const char *value)
 {
-	struct ast_channel *mchan = ast_channel_get_by_name(ast_channel_linkedid(chan));
+	struct ast_channel *mchan;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
+
+	mchan = ast_channel_get_by_name(ast_channel_linkedid(chan));
 	pbx_builtin_setvar_helper(mchan ? mchan : chan, data, value);
 	if (mchan) {
 		ast_channel_unref(mchan);

Modified: branches/12/funcs/func_dialplan.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_dialplan.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_dialplan.c (original)
+++ branches/12/funcs/func_dialplan.c Thu Mar 27 14:15:35 2014
@@ -96,20 +96,23 @@
 		int priority_num;
 		if (sscanf(args.priority, "%30d", &priority_num) == 1 && priority_num > 0) {
 			int res;
-			res = ast_exists_extension(chan, args.context, args.exten, priority_num, 
+			res = ast_exists_extension(chan, args.context, args.exten, priority_num,
+				!chan ? NULL :
 				S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
 			if (res)
 				strcpy(buf, "1");
 		} else {
 			int res;
 			res = ast_findlabel_extension(chan, args.context, args.exten, args.priority,
+				!chan ? NULL :
 				S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
 			if (res > 0)
 				strcpy(buf, "1");
 		}
 	} else if (!ast_strlen_zero(args.exten)) {
 		int res;
-		res = ast_exists_extension(chan, args.context, args.exten, 1, 
+		res = ast_exists_extension(chan, args.context, args.exten, 1,
+			!chan ? NULL :
 			S_COR(ast_channel_caller(chan)->id.number.valid, ast_channel_caller(chan)->id.number.str, NULL));
 		if (res)
 			strcpy(buf, "1");
@@ -133,6 +136,11 @@
 		AST_APP_ARG(priority);
 	);
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	AST_STANDARD_APP_ARGS(args, parse);
 
 	if (ast_strlen_zero(args.context)) {

Modified: branches/12/funcs/func_frame_trace.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_frame_trace.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_frame_trace.c (original)
+++ branches/12/funcs/func_frame_trace.c Thu Mar 27 14:15:35 2014
@@ -157,6 +157,11 @@
 	};
 	int i = 0;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (!(framedata = ast_calloc(1, sizeof(*framedata)))) {
 		return 0;
 	}

Modified: branches/12/funcs/func_global.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_global.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_global.c (original)
+++ branches/12/funcs/func_global.c Thu Mar 27 14:15:35 2014
@@ -173,6 +173,9 @@
 			return -1;
 		}
 		chan = c_ref;
+	} else if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
 	}
 
 	ast_channel_lock(chan);
@@ -233,6 +236,9 @@
 			return -1;
 		}
 		chan = c_ref;
+	} else if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
 	}
 
 	len = 9 + strlen(args.var); /* SHARED() + var */

Modified: branches/12/funcs/func_groupcount.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_groupcount.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_groupcount.c (original)
+++ branches/12/funcs/func_groupcount.c Thu Mar 27 14:15:35 2014
@@ -104,6 +104,11 @@
 	int count = -1;
 	char group[80] = "", category[80] = "";
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	ast_app_group_split_group(data, group, sizeof(group), category,
 				  sizeof(category));
 
@@ -174,9 +179,14 @@
 {
 	int ret = -1;
 	struct ast_group_info *gi = NULL;
-	
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	ast_app_group_list_rdlock();
-	
+
 	for (gi = ast_app_group_list_head(); gi; gi = AST_LIST_NEXT(gi, group_list)) {
 		if (gi->chan != chan)
 			continue;
@@ -200,6 +210,11 @@
 				char *data, const char *value)
 {
 	char grpcat[256];
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
 
 	if (!value) {
 		return -1;

Modified: branches/12/funcs/func_jitterbuffer.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_jitterbuffer.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_jitterbuffer.c (original)
+++ branches/12/funcs/func_jitterbuffer.c Thu Mar 27 14:15:35 2014
@@ -85,6 +85,11 @@
 {
 	struct ast_jb_conf jb_conf;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	/* Initialize and set jb_conf */
 	ast_jb_conf_default(&jb_conf);
 

Modified: branches/12/funcs/func_math.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_math.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_math.c (original)
+++ branches/12/funcs/func_math.c Thu Mar 27 14:15:35 2014
@@ -392,6 +392,11 @@
 		return -1;
 	}
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	ast_channel_lock(chan);
 
 	if (!(var = pbx_builtin_getvar_helper(chan, data))) {

Modified: branches/12/funcs/func_odbc.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_odbc.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_odbc.c (original)
+++ branches/12/funcs/func_odbc.c Thu Mar 27 14:15:35 2014
@@ -801,6 +801,11 @@
 	struct odbc_datastore *resultset;
 	struct odbc_datastore_row *row;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	ast_channel_lock(chan);
 	store = ast_channel_datastore_find(chan, &odbc_info, data);
 	if (!store) {

Modified: branches/12/funcs/func_pitchshift.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_pitchshift.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_pitchshift.c (original)
+++ branches/12/funcs/func_pitchshift.c Thu Mar 27 14:15:35 2014
@@ -200,6 +200,11 @@
 	int new = 0;
 	float amount = 0;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	ast_channel_lock(chan);
 	if (!(datastore = ast_channel_datastore_find(chan, &pitchshift_datastore, NULL))) {
 		ast_channel_unlock(chan);

Modified: branches/12/funcs/func_speex.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_speex.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_speex.c (original)
+++ branches/12/funcs/func_speex.c Thu Mar 27 14:15:35 2014
@@ -202,6 +202,11 @@
 	struct speex_direction_info **sdi = NULL;
 	int is_new = 0;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (strcasecmp(data, "rx") && strcasecmp(data, "tx")) {
 		ast_log(LOG_ERROR, "Invalid argument provided to the %s function\n", cmd);
 		return -1;

Modified: branches/12/funcs/func_strings.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_strings.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_strings.c (original)
+++ branches/12/funcs/func_strings.c Thu Mar 27 14:15:35 2014
@@ -1097,6 +1097,11 @@
 	struct ast_var_t *newvar;
 	struct ast_str *prefix = ast_str_alloca(80);
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	ast_str_set(&prefix, -1, HASH_PREFIX, data);
 	memset(buf, 0, len);
 
@@ -1118,6 +1123,11 @@
 	struct ast_var_t *newvar;
 	struct ast_str *prefix = ast_str_alloca(80);
 	char *tmp;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
 
 	ast_str_set(&prefix, -1, HASH_PREFIX, data);
 
@@ -1187,6 +1197,11 @@
 		AST_DECLARE_APP_ARGS(arg2,
 			AST_APP_ARG(col)[100];
 		);
+
+		if (!chan) {
+			ast_log(LOG_WARNING, "No channel and only 1 parameter was provided to %s function.\n", cmd);
+			return -1;
+		}
 
 		/* Get column names, in no particular order */
 		hashkeys_read(chan, "HASHKEYS", arg.hashname, colnames, sizeof(colnames));

Modified: branches/12/funcs/func_volume.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/funcs/func_volume.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/funcs/func_volume.c (original)
+++ branches/12/funcs/func_volume.c Thu Mar 27 14:15:35 2014
@@ -156,12 +156,17 @@
 	int is_new = 0;
 
 	/* Separate options from argument */
-	
+
 	AST_DECLARE_APP_ARGS(args,
 		AST_APP_ARG(direction);
 		AST_APP_ARG(options);
 	);
-	
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	AST_STANDARD_APP_ARGS(args, data);
 
 	ast_channel_lock(chan);

Modified: branches/12/main/features_config.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/features_config.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/main/features_config.c (original)
+++ branches/12/main/features_config.c Thu Mar 27 14:15:35 2014
@@ -1535,7 +1535,7 @@
 	return err;
 }
 
-static int feature_read(struct ast_channel *chan, const char *cmd, char *data,
+static int internal_feature_read(struct ast_channel *chan, const char *cmd, char *data,
 	       char *buf, size_t len)
 {
 	int res;
@@ -1566,7 +1566,7 @@
 	return res;
 }
 
-static int feature_write(struct ast_channel *chan, const char *cmd, char *data,
+static int internal_feature_write(struct ast_channel *chan, const char *cmd, char *data,
 		const char *value)
 {
 	int res;
@@ -1596,7 +1596,7 @@
 	return res;
 }
 
-static int featuremap_read(struct ast_channel *chan, const char *cmd, char *data,
+static int internal_featuremap_read(struct ast_channel *chan, const char *cmd, char *data,
 	       char *buf, size_t len)
 {
 	int res;
@@ -1611,7 +1611,7 @@
 	return res;
 }
 
-static int featuremap_write(struct ast_channel *chan, const char *cmd, char *data,
+static int internal_featuremap_write(struct ast_channel *chan, const char *cmd, char *data,
 		const char *value)
 {
 	int res;
@@ -1629,6 +1629,50 @@
 	}
 
 	return 0;
+}
+
+static int feature_read(struct ast_channel *chan, const char *cmd, char *data,
+		char *buf, size_t len)
+{
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	return internal_feature_read(chan, cmd, data, buf, len);
+}
+
+static int feature_write(struct ast_channel *chan, const char *cmd, char *data,
+		const char *value)
+{
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	return internal_feature_write(chan, cmd, data, value);
+}
+
+static int featuremap_read(struct ast_channel *chan, const char *cmd, char *data,
+		char *buf, size_t len)
+{
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	return internal_featuremap_read(chan, cmd, data, buf, len);
+}
+
+static int featuremap_write(struct ast_channel *chan, const char *cmd, char *data,
+		const char *value)
+{
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
+	return internal_featuremap_write(chan, cmd, data, value);
 }
 
 static struct ast_custom_function feature_function = {

Modified: branches/12/main/message.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/main/message.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/main/message.c (original)
+++ branches/12/main/message.c Thu Mar 27 14:15:35 2014
@@ -871,6 +871,11 @@
 	struct ast_datastore *ds;
 	struct ast_msg *msg;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
+
 	ast_channel_lock(chan);
 
 	if (!(ds = ast_channel_datastore_find(chan, &msg_datastore, NULL))) {
@@ -906,6 +911,11 @@
 {
 	struct ast_datastore *ds;
 	struct ast_msg *msg;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
 
 	ast_channel_lock(chan);
 
@@ -963,6 +973,11 @@
 	struct ast_msg *msg;
 	const char *val;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
+
 	ast_channel_lock(chan);
 
 	if (!(ds = ast_channel_datastore_find(chan, &msg_datastore, NULL))) {
@@ -992,6 +1007,11 @@
 {
 	struct ast_datastore *ds;
 	struct ast_msg *msg;
+
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", function);
+		return -1;
+	}
 
 	ast_channel_lock(chan);
 

Modified: branches/12/res/res_calendar.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_calendar.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/res/res_calendar.c (original)
+++ branches/12/res/res_calendar.c Thu Mar 27 14:15:35 2014
@@ -1685,6 +1685,11 @@
 	struct ast_datastore *datastore;
 	struct ast_calendar_event *event;
 
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	if (ast_strlen_zero(data)) {
 		ast_log(LOG_WARNING, "%s requires an argument\n", cmd);
 		return -1;

Modified: branches/12/res/res_jabber.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_jabber.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/res/res_jabber.c (original)
+++ branches/12/res/res_jabber.c Thu Mar 27 14:15:35 2014
@@ -845,7 +845,7 @@
 
 	start = ast_tvnow();
 
-	if (ast_autoservice_start(chan) < 0) {
+	if (chan && ast_autoservice_start(chan) < 0) {
 		ast_log(LOG_WARNING, "Cannot start autoservice for channel %s\n", ast_channel_name(chan));
 		ASTOBJ_UNREF(client, ast_aji_client_destroy);
 		return -1;
@@ -917,7 +917,7 @@
 	}
 
 	ASTOBJ_UNREF(client, ast_aji_client_destroy);
-	if (ast_autoservice_stop(chan) < 0) {
+	if (chan && ast_autoservice_stop(chan) < 0) {
 		ast_log(LOG_WARNING, "Cannot stop autoservice for channel %s\n", ast_channel_name(chan));
 	}
 

Modified: branches/12/res/res_mutestream.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_mutestream.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/res/res_mutestream.c (original)
+++ branches/12/res/res_mutestream.c Thu Mar 27 14:15:35 2014
@@ -155,6 +155,11 @@
 /*! \brief Mute dialplan function */
 static int func_mute_write(struct ast_channel *chan, const char *cmd, char *data, const char *value)
 {
+	if (!chan) {
+		ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+		return -1;
+	}
+
 	return mute_channel(chan, data, ast_true(value));
 }
 

Modified: branches/12/res/res_pjsip_header_funcs.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_pjsip_header_funcs.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/res/res_pjsip_header_funcs.c (original)
+++ branches/12/res/res_pjsip_header_funcs.c Thu Mar 27 14:15:35 2014
@@ -444,7 +444,7 @@
 static int func_read_header(struct ast_channel *chan, const char *function, char *data,
 							char *buf, size_t len)
 {
-	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(chan);
+	struct ast_sip_channel_pvt *channel = chan ? ast_channel_tech_pvt(chan) : NULL;
 	struct header_data header_data;
 	int number;
 	AST_DECLARE_APP_ARGS(args,
@@ -503,7 +503,7 @@
 static int func_write_header(struct ast_channel *chan, const char *cmd, char *data,
 							 const char *value)
 {
-	struct ast_sip_channel_pvt *channel = ast_channel_tech_pvt(chan);
+	struct ast_sip_channel_pvt *channel = chan ? ast_channel_tech_pvt(chan) : NULL;
 	struct header_data header_data;
 	int header_number;
 	AST_DECLARE_APP_ARGS(args,

Modified: branches/12/res/res_xmpp.c
URL: http://svnview.digium.com/svn/asterisk/branches/12/res/res_xmpp.c?view=diff&rev=411315&r1=411314&r2=411315
==============================================================================
--- branches/12/res/res_xmpp.c (original)
+++ branches/12/res/res_xmpp.c Thu Mar 27 14:15:35 2014
@@ -2045,7 +2045,7 @@
 
 	start = ast_tvnow();
 
-	if (ast_autoservice_start(chan) < 0) {
+	if (chan && ast_autoservice_start(chan) < 0) {
 		ast_log(LOG_WARNING, "Cannot start autoservice for channel %s\n", ast_channel_name(chan));
 		return -1;
 	}
@@ -2117,7 +2117,7 @@
 		diff = ast_tvdiff_ms(ast_tvnow(), start);
 	}
 
-	if (ast_autoservice_stop(chan) < 0) {
+	if (chan && ast_autoservice_stop(chan) < 0) {
 		ast_log(LOG_WARNING, "Cannot stop autoservice for channel %s\n", ast_channel_name(chan));
 	}
 




More information about the asterisk-commits mailing list