diff --git a/apps/app_speech_utils.c b/apps/app_speech_utils.c index 939a92f58e43b619d462a0e0331fdbc2ccd76086..c90bc8b5020695c7427dbecb7adc37dc822f6f47 100644 --- a/apps/app_speech_utils.c +++ b/apps/app_speech_utils.c @@ -202,6 +202,8 @@ static int speech_text(struct ast_channel *chan, const char *cmd, char *data, if (result->text != NULL) { ast_copy_string(buf, result->text, len); + } else { + buf[0] = '\0'; } return 0; @@ -230,6 +232,8 @@ static int speech_grammar(struct ast_channel *chan, const char *cmd, char *data, if (result->grammar != NULL) { ast_copy_string(buf, result->grammar, len); + } else { + buf[0] = '\0'; } return 0; @@ -330,6 +334,8 @@ static int speech_read(struct ast_channel *chan, const char *cmd, char *data, results++; snprintf(tmp, sizeof(tmp), "%d", results); ast_copy_string(buf, tmp, len); + } else { + buf[0] = '\0'; } return 0; diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c index 2714bb95a6178995fa48e8654fae18cd301fd59b..9282aed8944b5907053a7f78ce79f2a1ddb44bf7 100644 --- a/channels/chan_iax2.c +++ b/channels/chan_iax2.c @@ -11899,7 +11899,11 @@ static int function_iaxpeer(struct ast_channel *chan, const char *cmd, char *dat } if((codec = ast_codec_pref_index(&peer->prefs, atoi(codecnum)))) { ast_copy_string(buf, ast_getformatname(codec), len); + } else { + buf[0] = '\0'; } + } else { + buf[0] = '\0'; } peer_unref(peer); diff --git a/channels/chan_sip.c b/channels/chan_sip.c index 4bebce8670083b83297fc7811f114da5c2310cba..df946846243b2ce59452c8b5e437d5829075cdc4 100644 --- a/channels/chan_sip.c +++ b/channels/chan_sip.c @@ -14959,7 +14959,11 @@ static int function_sippeer(struct ast_channel *chan, const char *cmd, char *dat codecnum = strsep(&codecnum, "]"); /* trim trailing ']' if any */ if((codec = ast_codec_pref_index(&peer->prefs, atoi(codecnum)))) { ast_copy_string(buf, ast_getformatname(codec), len); + } else { + buf[0] = '\0'; } + } else { + buf[0] = '\0'; } unref_peer(peer, "unref_peer from function_sippeer, just before return"); diff --git a/funcs/func_callerid.c b/funcs/func_callerid.c index 9dfe0d8c7c4dcbf8e823e7de36aaf6dcfaef974b..b59f57a44d53e360732a825db9bea257f9897a47 100644 --- a/funcs/func_callerid.c +++ b/funcs/func_callerid.c @@ -51,6 +51,7 @@ static int callerpres_write(struct ast_channel *chan, const char *cmd, char *dat static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { + int res = -1; char *opt = data; if (!chan) @@ -64,10 +65,13 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, if (!strncasecmp("all", data, 3)) { snprintf(buf, len, "\"%s\" <%s>", name, num); + res = 0; } else if (!strncasecmp("name", data, 4)) { ast_copy_string(buf, name, len); + res = 0; } else if (!strncasecmp("num", data, 3)) { ast_copy_string(buf, num, len); + res = 0; } else { ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); } @@ -78,32 +82,40 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, snprintf(buf, len, "\"%s\" <%s>", S_OR(chan->cid.cid_name, ""), S_OR(chan->cid.cid_num, "")); + res = 0; } else if (!strncasecmp("name", data, 4)) { if (chan->cid.cid_name) { ast_copy_string(buf, chan->cid.cid_name, len); + res = 0; } } else if (!strncasecmp("num", data, 3)) { if (chan->cid.cid_num) { ast_copy_string(buf, chan->cid.cid_num, len); + res = 0; } } else if (!strncasecmp("ani", data, 3)) { if (!strncasecmp(data + 3, "2", 1)) { snprintf(buf, len, "%d", chan->cid.cid_ani2); } else if (chan->cid.cid_ani) { ast_copy_string(buf, chan->cid.cid_ani, len); + res = 0; } } else if (!strncasecmp("dnid", data, 4)) { if (chan->cid.cid_dnid) { ast_copy_string(buf, chan->cid.cid_dnid, len); + res = 0; } } else if (!strncasecmp("rdnis", data, 5)) { if (chan->cid.cid_rdnis) { ast_copy_string(buf, chan->cid.cid_rdnis, len); + res = 0; } } else if (!strncasecmp("pres", data, 4)) { ast_copy_string(buf, ast_named_caller_presentation(chan->cid.cid_pres), len); + res = 0; } else if (!strncasecmp("ton", data, 3)) { snprintf(buf, len, "%d", chan->cid.cid_ton); + res = 0; } else { ast_log(LOG_ERROR, "Unknown callerid data type '%s'.\n", data); } @@ -111,7 +123,7 @@ static int callerid_read(struct ast_channel *chan, const char *cmd, char *data, ast_channel_unlock(chan); } - return 0; + return res; } static int callerid_write(struct ast_channel *chan, const char *cmd, char *data, diff --git a/funcs/func_cdr.c b/funcs/func_cdr.c index 3ea1a300831661daa8720e8635890976f515028b..9b73d03f18ed70fea30bca41665377e6d7530df8 100644 --- a/funcs/func_cdr.c +++ b/funcs/func_cdr.c @@ -84,7 +84,7 @@ static int cdr_read(struct ast_channel *chan, const char *cmd, char *parse, ast_test_flag(&flags, OPT_RECURSIVE), ast_test_flag(&flags, OPT_UNPARSED)); - return 0; + return ret ? 0 : -1; } static int cdr_write(struct ast_channel *chan, const char *cmd, char *parse, diff --git a/funcs/func_curl.c b/funcs/func_curl.c index 107b4e11e665b12a2ec186c64a29bfe6931cba45..e385ed9e179d0934c453f2db6b059b1245227014 100644 --- a/funcs/func_curl.c +++ b/funcs/func_curl.c @@ -397,6 +397,7 @@ AST_THREADSTORAGE_CUSTOM(curl_instance, curl_instance_init, curl_instance_cleanu static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info, char *buf, size_t len) { struct ast_str *str = ast_str_create(16); + int ret = -1; AST_DECLARE_APP_ARGS(args, AST_APP_ARG(url); AST_APP_ARG(postdata); @@ -494,13 +495,14 @@ static int acf_curl_exec(struct ast_channel *chan, const char *cmd, char *info, } else { ast_copy_string(buf, str->str, len); } + ret = 0; } ast_free(str); if (chan) ast_autoservice_stop(chan); - return 0; + return ret; } struct ast_custom_function acf_curl = { diff --git a/funcs/func_groupcount.c b/funcs/func_groupcount.c index f0d7df1b5f791c6b40d05882f5ca5b99cdc2ab3a..b70a42e94ae13a5f9e2ccf835915ee23cca5ecfa 100644 --- a/funcs/func_groupcount.c +++ b/funcs/func_groupcount.c @@ -34,6 +34,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$") static int group_count_function_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { + int ret = -1; int count = -1; char group[80] = "", category[80] = ""; @@ -59,12 +60,14 @@ static int group_count_function_read(struct ast_channel *chan, const char *cmd, ast_app_group_list_unlock(); } - if ((count = ast_app_group_get_count(group, category)) == -1) + if ((count = ast_app_group_get_count(group, category)) == -1) { ast_log(LOG_NOTICE, "No group could be found for channel '%s'\n", chan->name); - else + } else { snprintf(buf, len, "%d", count); + ret = 0; + } - return 0; + return ret; } static struct ast_custom_function group_count_function = { @@ -91,9 +94,10 @@ static int group_match_count_function_read(struct ast_channel *chan, if (!ast_strlen_zero(group)) { count = ast_app_group_match_get_count(group, category); snprintf(buf, len, "%d", count); + return 0; } - return 0; + return -1; } static struct ast_custom_function group_match_count_function = { @@ -111,6 +115,7 @@ static struct ast_custom_function group_match_count_function = { static int group_function_read(struct ast_channel *chan, const char *cmd, char *data, char *buf, size_t len) { + int ret = -1; struct ast_group_info *gi = NULL; ast_app_group_list_rdlock(); @@ -124,12 +129,14 @@ static int group_function_read(struct ast_channel *chan, const char *cmd, break; } - if (gi) + if (gi) { ast_copy_string(buf, gi->group, len); + ret = 0; + } ast_app_group_list_unlock(); - return 0; + return ret; } static int group_function_write(struct ast_channel *chan, const char *cmd, diff --git a/funcs/func_math.c b/funcs/func_math.c index 45036d5ad76dae7e855809252aaf5a40d6e049a2..3517b16ed186be54f5ef3eaaa2b101f5ba609944 100644 --- a/funcs/func_math.c +++ b/funcs/func_math.c @@ -82,14 +82,14 @@ static int math(struct ast_channel *chan, const char *cmd, char *parse, ); if (ast_strlen_zero(parse)) { - ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n"); + ast_log(LOG_WARNING, "Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n"); return -1; } AST_STANDARD_APP_ARGS(args, parse); if (args.argc < 1) { - ast_log(LOG_WARNING, "Syntax: Math(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n"); + ast_log(LOG_WARNING, "Syntax: MATH(<number1><op><number 2>[,<type_of_result>]) - missing argument!\n"); return -1; } diff --git a/funcs/func_odbc.c b/funcs/func_odbc.c index 0925f7c034124346ce683ac2716d987b8b622889..da7e3eccd901715ee54285bf90b5ad9ada97b914 100644 --- a/funcs/func_odbc.c +++ b/funcs/func_odbc.c @@ -367,6 +367,7 @@ static int acf_odbc_read(struct ast_channel *chan, const char *cmd, char *s, cha if (res == SQL_NO_DATA) { ast_verb(4, "Found no rows [%s]\n", sql->str); res1 = 0; + buf[0] = '\0'; ast_copy_string(rowcount, "0", sizeof(rowcount)); } else { ast_log(LOG_WARNING, "Error %d in FETCH [%s]\n", res, sql->str); @@ -517,6 +518,8 @@ end_acf_read: } odbc_store->data = resultset; ast_channel_datastore_add(chan, odbc_store); + } else { + buf[0] = '\0'; } SQLCloseCursor(stmt); SQLFreeHandle(SQL_HANDLE_STMT, stmt); diff --git a/funcs/func_timeout.c b/funcs/func_timeout.c index 33db35e3d6aa2231dfff787d5bd150030a1fa823..625070217b99d25edc1e89dba8287f6f5ffb1368 100644 --- a/funcs/func_timeout.c +++ b/funcs/func_timeout.c @@ -74,7 +74,7 @@ static int timeout_read(struct ast_channel *chan, const char *cmd, char *data, default: ast_log(LOG_ERROR, "Unknown timeout type specified.\n"); - break; + return -1; } return 0; diff --git a/res/res_smdi.c b/res/res_smdi.c index 88f562b2d7353681d79d1ca50be5d25c6d33b727..d3440f9d2142e526b5910f9f2c7979f1fa7a65a3 100644 --- a/res/res_smdi.c +++ b/res/res_smdi.c @@ -1260,7 +1260,7 @@ static int smdi_msg_read(struct ast_channel *chan, const char *cmd, char *data, return_error: ast_module_user_remove(u); - return 0; + return res; } static struct ast_custom_function smdi_msg_retrieve_function = {