]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Fix dialplan function NULL channel safety issues
authorCorey Farrell <git@cfware.com>
Thu, 27 Mar 2014 19:13:09 +0000 (19:13 +0000)
committerCorey Farrell <git@cfware.com>
Thu, 27 Mar 2014 19:13:09 +0000 (19:13 +0000)
(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

git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/11@411314 65c4cc65-6c06-0410-ace0-fbb531ad65f3

28 files changed:
apps/app_jack.c
apps/app_speech_utils.c
apps/app_stack.c
apps/app_voicemail.c
apps/confbridge/conf_config_parser.c
channels/chan_iax2.c
channels/chan_sip.c
funcs/func_blacklist.c
funcs/func_callcompletion.c
funcs/func_callerid.c
funcs/func_channel.c
funcs/func_dialplan.c
funcs/func_frame_trace.c
funcs/func_global.c
funcs/func_groupcount.c
funcs/func_jitterbuffer.c
funcs/func_math.c
funcs/func_odbc.c
funcs/func_pitchshift.c
funcs/func_speex.c
funcs/func_strings.c
funcs/func_volume.c
main/features.c
main/message.c
res/res_calendar.c
res/res_jabber.c
res/res_mutestream.c
res/res_xmpp.c

index d1bdfa38f052f4143016332054e114aacdfe201b..f32c59ff0b6fa295e9af8eecadf4c7f86a6e25a8 100644 (file)
@@ -951,6 +951,11 @@ static int jack_hook_write(struct ast_channel *chan, const char *cmd, char *data
 {
        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"))
index 3e071c07a888d4384fb9f0997bb263d9a2931d28..c0829c32fd1eda59faf6e4f9e6ad87368852a355 100644 (file)
@@ -284,7 +284,11 @@ static struct ast_speech *find_speech(struct ast_channel *chan)
 {
        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;
index 20b03087f3958cd8328a82509099e5ca11131569..dcd35d235b1b3191e7f091a3e0871b7bc871eeef 100644 (file)
@@ -687,6 +687,11 @@ static int local_read(struct ast_channel *chan, const char *cmd, char *data, cha
        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);
@@ -721,6 +726,11 @@ static int local_write(struct ast_channel *chan, const char *cmd, char *var, con
        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))) {
                ast_log(LOG_ERROR, "Tried to set LOCAL(%s), but we aren't within a Gosub routine\n", var);
index 3158efd46953c7179ca2ae89a82b9cf0b2ab593e..1fb5160ea072a548d0610168c02b60afd7d98383 100644 (file)
@@ -12045,7 +12045,9 @@ static int acf_vm_info(struct ast_channel *chan, const char *cmd, char *args, ch
                } 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) : 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)) {
index cddf2732f6b1674b365cf6c87580edf7d4fbd351..93cde54a3c9ec74c3971d2892a0a9b0433d9afa4 100644 (file)
@@ -354,6 +354,11 @@ int func_confbridge_helper(struct ast_channel *chan, const char *cmd, char *data
                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;
index 64f50f2c77f81759f737c94405353b04703ca034..a288644785645ce0d339cde393c47cb877de5a03 100644 (file)
@@ -10013,10 +10013,16 @@ static int socket_process_meta(int packet_len, struct ast_iax2_meta_hdr *meta, s
 
 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;
@@ -10036,10 +10042,16 @@ static int acf_iaxvar_read(struct ast_channel *chan, const char *cmd, char *data
 
 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) {
@@ -14307,8 +14319,9 @@ static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *dat
        /* 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, iaxs[callno]->addr.sin_addr.s_addr ? ast_inet_ntoa(iaxs[callno]->addr.sin_addr) : "", len);
                return 0;
index eae51bbd05657e4d6ea26c92559f201d6c4f4390..018bd2d6819d1f9095da5526b6684140e3244fed 100644 (file)
@@ -21992,7 +21992,12 @@ static int func_header_read(struct ast_channel *chan, const char *function, char
        );
        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;
        }
@@ -22177,8 +22182,13 @@ static int function_sipchaninfo_read(struct ast_channel *chan, const char *cmd,
        static int deprecated = 0;
 
        *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;
        }
index 928d5d728a35e020917c12d0767aa17232f7347a..bb045059b2acf9e1ed42698fc855af33f5e571a1 100644 (file)
@@ -61,6 +61,11 @@ static int blacklist_read(struct ast_channel *chan, const char *cmd, char *data,
        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;
index cee06faa47ad50edad2a1a85605ff3a4d55de757..cb1cd59b3f1f9d837c12cb4afb7b5cba983fd564 100644 (file)
@@ -74,6 +74,11 @@ static int acf_cc_read(struct ast_channel *chan, const char *name, char *data,
        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);
@@ -91,6 +96,11 @@ static int acf_cc_write(struct ast_channel *chan, const char *cmd, char *data,
        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))) {
                ast_channel_unlock(chan);
index 789575399e81cad9214e435be220f6893535eb13..1af42183e693ecd5c9b791c55a620d1da52a8ef3 100644 (file)
@@ -900,6 +900,11 @@ static int callerpres_deprecate_notify;
  */
 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."
@@ -926,6 +931,11 @@ static int callerpres_write(struct ast_channel *chan, const char *cmd, char *dat
 {
        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;
                ast_log(LOG_WARNING, "CALLERPRES is deprecated."
index 4180eeaa7f156097b44bfed9f24a69194b75bcd1..00dfba90e5d729b11219d9b367c62b78ada02c40 100644 (file)
@@ -405,6 +405,11 @@ static int func_channel_read(struct ast_channel *chan, const char *function,
        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];
 
@@ -703,6 +708,11 @@ static int func_channel_write(struct ast_channel *chan, const char *function, ch
                .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);
 
@@ -776,8 +786,15 @@ static struct ast_custom_function channels_function = {
 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) {
@@ -789,7 +806,14 @@ static int func_mchan_read(struct ast_channel *chan, const char *function,
 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);
index d06ddba9a671a1bf0555318601313cf692a333bf..02b4c7a9e48afff56e20dc4a26b47253cc6b34f5 100644 (file)
@@ -96,20 +96,23 @@ static int isexten_function_read(struct ast_channel *chan, const char *cmd, char
                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 @@ static int acf_isexten_exec(struct ast_channel *chan, const char *cmd, char *par
                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)) {
index 8e12aafb3547e609359d1fde41d85b074383d536..90778e23cdadbd583413d5d446957b26156b0030 100644 (file)
@@ -157,6 +157,11 @@ static int frame_trace_helper(struct ast_channel *chan, const char *cmd, char *d
        };
        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;
        }
index 405ac0b92f99a07fe4e7ad606f148758c03ae5ef..dcf0393520bdd48f6ced182f63b4dbfd22848f76 100644 (file)
@@ -155,6 +155,9 @@ static int shared_read(struct ast_channel *chan, const char *cmd, char *data, ch
                        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);
@@ -213,6 +216,9 @@ static int shared_write(struct ast_channel *chan, const char *cmd, char *data, c
                        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);
index 95ee0cde6181b8e6870a23502eb52dcd6faa6962..4ea6816918d98f36094f02e0ccab53e861b9daa5 100644 (file)
@@ -104,6 +104,11 @@ static int group_count_function_read(struct ast_channel *chan, const char *cmd,
        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 @@ static int group_function_read(struct ast_channel *chan, const char *cmd,
 {
        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;
@@ -201,6 +211,11 @@ static int group_function_write(struct ast_channel *chan, const char *cmd,
 {
        char grpcat[256];
 
+       if (!chan) {
+               ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+               return -1;
+       }
+
        if (!value) {
                return -1;
        }
index 066d9d2f626ec9c8b1e6dd0c98409eb11b5a3f7b..1e90a5c5e3bf12359ba8c94eb7eaea08f892c13b 100644 (file)
@@ -325,6 +325,11 @@ static int jb_helper(struct ast_channel *chan, const char *cmd, char *data, cons
        };
        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;
        }
index 36f3fc48a6848f32253900bee8e7d4b88e6c4175..2bc68c579a8ea9aab86b2d88f8b151349fccc41a 100644 (file)
@@ -392,6 +392,11 @@ static int crement_function_read(struct ast_channel *chan, const char *cmd,
                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))) {
index 4469ca7a272b0f04d3e89c29778aea4f22dec5ea..5e7655f908c9008549a3941336f6f4459ac7a5e6 100644 (file)
@@ -801,6 +801,11 @@ static int acf_fetch(struct ast_channel *chan, const char *cmd, char *data, char
        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) {
index ca441f985079d9385f6cb655012c9e7c02a9aab8..e5091d95dd8be46ca7131ac930cc697a724f539d 100644 (file)
@@ -200,6 +200,11 @@ static int pitchshift_helper(struct ast_channel *chan, const char *cmd, char *da
        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);
index fb5addbb4adf66935ef690f26fc15ca445624974..7da3e876d72fe13745192e2777ff361b0ad12682 100644 (file)
@@ -202,6 +202,11 @@ static int speex_write(struct ast_channel *chan, const char *cmd, char *data, co
        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;
index 8b4d8f7007c195e68e2970970a91f8c31a1da2e4..57b772088799264ba8d491b876db24d5ab2a11e6 100644 (file)
@@ -1097,6 +1097,11 @@ static int hashkeys_read(struct ast_channel *chan, const char *cmd, char *data,
        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);
 
@@ -1119,6 +1124,11 @@ static int hashkeys_read2(struct ast_channel *chan, const char *cmd, char *data,
        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);
 
        AST_LIST_TRAVERSE(ast_channel_varshead(chan), newvar, entries) {
@@ -1188,6 +1198,11 @@ static int hash_read(struct ast_channel *chan, const char *cmd, char *data, char
                        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));
                pbx_builtin_setvar_helper(chan, "~ODBCFIELDS~", colnames);
index 953a37dcdd97423018133f0ec0413f0babcac454..9fd02008fe8e1458d01cdbf967f33806834a1058 100644 (file)
@@ -156,12 +156,17 @@ static int volume_write(struct ast_channel *chan, const char *cmd, char *data, c
        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);
index e23a47e3c5690e9ea53d10f033a76d31f3e9a78f..d21d92d78ce2979ada3cbe77560d43a71419ed07 100644 (file)
@@ -8913,6 +8913,11 @@ static int feature_read(struct ast_channel *chan, const char *cmd, char *data,
 {
        int res = 0;
 
+       if (!chan) {
+               ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+               return -1;
+       }
+
        if (!strcasecmp(data, "parkingtime")) {
                snprintf(buf, len, "%u", get_parkingtime(chan, NULL) / 1000);
        } else {
@@ -8929,6 +8934,11 @@ static int feature_write(struct ast_channel *chan, const char *cmd, char *data,
        int res = 0;
        struct feature_ds *feature_ds;
 
+       if (!chan) {
+               ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+               return -1;
+       }
+
        ast_channel_lock(chan);
 
        if (!(feature_ds = get_feature_ds(chan))) {
@@ -8961,6 +8971,11 @@ static int featuremap_read(struct ast_channel *chan, const char *cmd, char *data
 {
        int res;
 
+       if (!chan) {
+               ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+               return -1;
+       }
+
        ast_rdlock_call_features();
 
        if ((res = builtin_feature_get_exten(chan, data, buf, len))) {
@@ -8978,6 +8993,11 @@ static int featuremap_write(struct ast_channel *chan, const char *cmd, char *dat
        struct feature_ds *feature_ds;
        struct feature_exten *fe;
 
+       if (!chan) {
+               ast_log(LOG_WARNING, "No channel was provided to %s function.\n", cmd);
+               return -1;
+       }
+
        if (!ast_find_call_feature(data)) {
                ast_log(LOG_WARNING, "Invalid argument '%s' to FEATUREMAP()\n", data);
                return -1;
index bb98e24d992dacdb7e4f8bd0e3aee5edf0c1a9f4..327d3b0c55ae7699bf92fd3ca8ab04b33f422f4d 100644 (file)
@@ -867,6 +867,11 @@ static int msg_func_read(struct ast_channel *chan, const char *function,
        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))) {
@@ -903,6 +908,11 @@ static int msg_func_write(struct ast_channel *chan, const char *function,
        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 = msg_datastore_find_or_create(chan))) {
@@ -959,6 +969,11 @@ static int msg_data_func_read(struct ast_channel *chan, const char *function,
        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))) {
@@ -989,6 +1004,11 @@ static int msg_data_func_write(struct ast_channel *chan, const char *function,
        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 = msg_datastore_find_or_create(chan))) {
index 0ec032cf99e31a405131537a935e4e61d0412e3b..1691d29a2be4f761c83b4a792b566c37ee524d84 100644 (file)
@@ -1673,6 +1673,11 @@ static int calendar_event_read(struct ast_channel *chan, const char *cmd, char *
        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;
index 72195f22fa4f041073d5721bbf888f1ee6c978f7..e4556254aeb497b63ad67dd190e0925595189fa4 100644 (file)
@@ -837,7 +837,7 @@ static int acf_jabberreceive_read(struct ast_channel *chan, const char *name, ch
 
        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;
@@ -909,7 +909,7 @@ static int acf_jabberreceive_read(struct ast_channel *chan, const char *name, ch
        }
 
        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));
        }
 
index f7032eacf79a1a066f1c1336c3901b6075d20ae7..2fc8a4964d614628139a7660158c3fe1cf63ba3f 100644 (file)
@@ -235,6 +235,11 @@ static int func_mute_write(struct ast_channel *chan, const char *cmd, char *data
        int is_new = 0;
        int turnon;
 
+       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, &mute_datastore, NULL))) {
                if (!(datastore = initialize_mutehook(chan))) {
index b5d0e8a88c6c45de3099aa3ca58ac25257a4494c..a011d5e5ff9497d45617a2fc0bd3499c8535c386 100644 (file)
@@ -1923,7 +1923,7 @@ static int acf_jabberreceive_read(struct ast_channel *chan, const char *name, ch
 
        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;
        }
@@ -1995,7 +1995,7 @@ static int acf_jabberreceive_read(struct ast_channel *chan, const char *name, ch
                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));
        }