]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
Massive cleanups to applications for LOCAL_USER handling and some other things.
authorRussell Bryant <russell@russellbryant.com>
Wed, 19 Oct 2005 18:19:02 +0000 (18:19 +0000)
committerRussell Bryant <russell@russellbryant.com>
Wed, 19 Oct 2005 18:19:02 +0000 (18:19 +0000)
In general, LOCAL_USER_ADD/REMOVE should be the first/last thing called in an
application.  An exception is if there is some *fast* setup code that might
halt the execution of the application, such as checking to see if an argument
exists.

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

74 files changed:
apps/app_adsiprog.c
apps/app_alarmreceiver.c
apps/app_authenticate.c
apps/app_cdr.c
apps/app_chanisavail.c
apps/app_chanspy.c
apps/app_controlplayback.c
apps/app_curl.c
apps/app_cut.c
apps/app_db.c
apps/app_dial.c
apps/app_dictate.c
apps/app_directed_pickup.c
apps/app_directory.c
apps/app_disa.c
apps/app_dumpchan.c
apps/app_enumlookup.c
apps/app_eval.c
apps/app_externalivr.c
apps/app_festival.c
apps/app_groupcount.c
apps/app_hasnewvoicemail.c
apps/app_ices.c
apps/app_image.c
apps/app_intercom.c
apps/app_ivrdemo.c
apps/app_macro.c
apps/app_math.c
apps/app_md5.c
apps/app_meetme.c
apps/app_milliwatt.c
apps/app_mixmonitor.c
apps/app_mp3.c
apps/app_muxmon.c
apps/app_nbscat.c
apps/app_osplookup.c
apps/app_page.c
apps/app_parkandannounce.c
apps/app_playback.c
apps/app_queue.c
apps/app_random.c
apps/app_read.c
apps/app_readfile.c
apps/app_realtime.c
apps/app_record.c
apps/app_senddtmf.c
apps/app_sendtext.c
apps/app_setcallerid.c
apps/app_setcdruserfield.c
apps/app_setcidname.c
apps/app_setcidnum.c
apps/app_setrdnis.c
apps/app_settransfercapability.c
apps/app_skel.c
apps/app_sms.c
apps/app_softhangup.c
apps/app_sql_postgres.c
apps/app_striplsd.c
apps/app_substring.c
apps/app_system.c
apps/app_talkdetect.c
apps/app_test.c
apps/app_transfer.c
apps/app_txtcidname.c
apps/app_url.c
apps/app_userevent.c
apps/app_verbose.c
apps/app_voicemail.c
apps/app_waitforring.c
apps/app_waitforsilence.c
apps/app_while.c
apps/app_zapateller.c
apps/app_zapbarge.c
apps/app_zapras.c

index bf6260bde1c7443965305b48a13a83230bb42047..8e9d3bf1cea0a73fd244019d3c9639fc09439639 100755 (executable)
@@ -1553,9 +1553,12 @@ static int adsi_exec(struct ast_channel *chan, void *data)
 {
        int res=0;
        struct localuser *u;
+
+       LOCAL_USER_ADD(u);
+       
        if (!data || ast_strlen_zero(data))
                data = "asterisk.adsi";
-       LOCAL_USER_ADD(u);
+       
        if (!adsi_available(chan)) {
                if (option_verbose > 2)
                        ast_verbose(VERBOSE_PREFIX_3 "ADSI Unavailable on CPE.  Not bothering to try.\n");
@@ -1564,7 +1567,9 @@ static int adsi_exec(struct ast_channel *chan, void *data)
                        ast_verbose(VERBOSE_PREFIX_3 "ADSI Available on CPE.  Attempting Upload.\n");
                res = adsi_prog(chan, data);
        }
+
        LOCAL_USER_REMOVE(u);
+       
        return res;
 }
 
index 4513acf0f886e3bb45846a19f38033ed4a5fb31e..9c3843f201c60bb2102936f5f0b82c5cb1a5d8b9 100755 (executable)
@@ -652,11 +652,13 @@ static int alarmreceiver_exec(struct ast_channel *chan, void *data)
 
        if (ast_set_write_format(chan,AST_FORMAT_ULAW)){
                ast_log(LOG_WARNING, "AlarmReceiver: Unable to set write format to Mu-law on %s\n",chan->name);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        
        if (ast_set_read_format(chan,AST_FORMAT_ULAW)){
                ast_log(LOG_WARNING, "AlarmReceiver: Unable to set read format to Mu-law on %s\n",chan->name);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
index d9e69fd4303e2631018e07fddccd1b4f247ac33e..e2b286fd4cc1d539ae6099eb998dde99341f6c5d 100755 (executable)
@@ -85,11 +85,14 @@ static int auth_exec(struct ast_channel *chan, void *data)
        char passwd[256];
        char *opts;
        char *prompt;
+       
        if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Authenticate requires an argument(password)\n");
                return -1;
        }
+       
        LOCAL_USER_ADD(u);
+
        if (chan->_state != AST_STATE_UP) {
                res = ast_answer(chan);
                if (res) {
@@ -97,6 +100,7 @@ static int auth_exec(struct ast_channel *chan, void *data)
                        return -1;
                }
        }
+       
        strncpy(password, data, sizeof(password) - 1);
        opts=strchr(password, '|');
        if (opts) {
index e5d18faadcfa892ff75f12ac4f6afd82089fb93b..80d136c35c27dd87f546bdfc0919826b6aac28c3 100755 (executable)
@@ -46,10 +46,17 @@ LOCAL_USER_DECL;
 
 static int nocdr_exec(struct ast_channel *chan, void *data)
 {
+       struct localuser *u;
+       
+       LOCAL_USER_ADD(u);
+
        if (chan->cdr) {
                ast_cdr_free(chan->cdr);
                chan->cdr = NULL;
        }
+
+       LOCAL_USER_REMOVE(u);
+
        return 0;
 }
 
index 6f60fba155333c51e545cb5a191a97484cd640d4..5c9d4e707a2f6ab7bfc4a784e38084868e11d7d2 100755 (executable)
@@ -72,16 +72,17 @@ static int chanavail_exec(struct ast_channel *chan, void *data)
        int res=-1, inuse=-1, option_state=0;
        int status;
        struct localuser *u;
-       char info[512], tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur, *options, *stringp;
+       char *info, tmp[512], trychan[512], *peers, *tech, *number, *rest, *cur, *options, *stringp;
        struct ast_channel *tempchan;
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "ChanIsAvail requires an argument (Zap/1&Zap/2)\n");
                return -1;
        }
+
        LOCAL_USER_ADD(u);
 
-       strncpy(info, (char *)data, sizeof(info)-1);
+       info = ast_strdupa(data); 
        stringp = info;
        strsep(&stringp, "|");
        options = strsep(&stringp, "|");
index defb190fee0589be494608ed3d51dacf8dc8dfa3..fefce3163b769836af4f146cab0c65490abbeadd 100755 (executable)
@@ -540,24 +540,26 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
                return -1;
        }
 
+       LOCAL_USER_ADD(u);
+
        oldrf = chan->readformat;
        oldwf = chan->writeformat;
        if (ast_set_read_format(chan, AST_FORMAT_SLINEAR) < 0) {
                ast_log(LOG_ERROR, "Could Not Set Read Format.\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        
        if (ast_set_write_format(chan, AST_FORMAT_SLINEAR) < 0) {
                ast_log(LOG_ERROR, "Could Not Set Write Format.\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
        ast_answer(chan);
 
        ast_set_flag(chan, AST_FLAG_SPYING); /* so nobody can spy on us while we are spying */
 
-
        if ((argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
                spec = argv[0];
                if ( argc > 1) {
index 8576cbb799aeea2307b4563e90c4cdd9acb464ea..2a75c8652fe174cc6a95a8facb9c506a04de9f7e 100755 (executable)
@@ -81,12 +81,14 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
                arg_pause = 5,
                arg_restart = 6,
        };
-
-       if (!data || ast_strlen_zero((char *)data)) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n");
                return -1;
        }
 
+       LOCAL_USER_ADD(u);
+       
        tmp = ast_strdupa(data);
        memset(argv, 0, sizeof(argv));
 
@@ -94,6 +96,7 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
 
        if (argc < 1) {
                ast_log(LOG_WARNING, "ControlPlayback requires an argument (filename)\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
@@ -112,12 +115,8 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
        if (argv[arg_restart] && !is_on_phonepad(*argv[arg_restart]))
                argv[arg_restart] = NULL;
 
-       LOCAL_USER_ADD(u);
-
        res = ast_control_streamfile(chan, argv[arg_file], argv[arg_fwd], argv[arg_rev], argv[arg_stop], argv[arg_pause], argv[arg_restart], skipms);
 
-       LOCAL_USER_REMOVE(u);
-       
        /* If we stopped on one of our stop keys, return 0  */
        if (argv[arg_stop] && strchr(argv[arg_stop], res)) 
                res = 0;
@@ -127,6 +126,8 @@ static int controlplayback_exec(struct ast_channel *chan, void *data)
                        res = 0;
        }
 
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index e146585bc6e39a4c362c5e82ba562cf0827240ce..c43d1a90e56a31c10cde47654bcca8f93365de11 100755 (executable)
@@ -118,27 +118,28 @@ static int curl_exec(struct ast_channel *chan, void *data)
        char *info, *post_data=NULL, *url;
        struct MemoryStruct chunk = { NULL, 0 };
        static int dep_warning = 0;
-
-       if (!data || !strlen((char *)data)) {
-               ast_log(LOG_WARNING, "Curl requires an argument (URL)\n");
-               return -1;
-       }
-
+       
        if (!dep_warning) {
                ast_log(LOG_WARNING, "The application Curl is deprecated.  Please use the CURL() function instead.\n");
                dep_warning = 1;
        }
 
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "Curl requires an argument (URL)\n");
+               return -1;
+       }
+       
+       LOCAL_USER_ADD(u);
+       
        if ((info = ast_strdupa((char *)data))) {
                url = strsep(&info, "|");
                post_data = info;
        } else {
                ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
-
        if (! curl_internal(&chunk, url, post_data)) {
                if (chunk.memory) {
                        chunk.memory[chunk.size] = '\0';
@@ -164,23 +165,25 @@ static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char
        char *info, *post_data=NULL, *url;
        struct MemoryStruct chunk = { NULL, 0 };
 
-       if (!data || !strlen((char *)data)) {
+       *buf = '\0';
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "CURL requires an argument (URL)\n");
-               *buf = '\0';
                return buf;
        }
 
-       if ((info = ast_strdupa((char *)data))) {
-               url = strsep(&info, "|");
-               post_data = info;
-       } else {
+       LOCAL_USER_ACF_ADD(u);
+
+       info = ast_strdupa(data);
+       if (!info) {
                ast_log(LOG_ERROR, "Out of memory\n");
-               *buf = '\0';
+               LOCAL_USER_REMOVE(u);
                return buf;
        }
-
-       LOCAL_USER_ACF_ADD(u);
-
+       
+       url = strsep(&info, "|");
+       post_data = info;
+       
        if (! curl_internal(&chunk, url, post_data)) {
                if (chunk.memory) {
                        chunk.memory[chunk.size] = '\0';
@@ -192,7 +195,6 @@ static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char
                }
        } else {
                ast_log(LOG_ERROR, "Cannot allocate curl structure\n");
-               *buf = '\0';
        }
 
        LOCAL_USER_REMOVE(u);
index 96f0f9c3f0cc5257ca612f7ef5ed537523365099..bc270371d40e021ba9478c651edb0d42e9f9150a 100755 (executable)
@@ -262,7 +262,6 @@ static int sort_exec(struct ast_channel *chan, void *data)
        char *varname, *strings, result[512] = "";
        static int dep_warning=0;
 
-       LOCAL_USER_ADD(u);
        if (!dep_warning) {
                ast_log(LOG_WARNING, "The application Sort is deprecated.  Please use the SORT() function instead.\n");
                dep_warning=1;
@@ -270,10 +269,11 @@ static int sort_exec(struct ast_channel *chan, void *data)
 
        if (!data) {
                ast_log(LOG_ERROR, "Sort() requires an argument\n");
-               LOCAL_USER_REMOVE(u);
                return 0;
        }
 
+       LOCAL_USER_ADD(u);
+
        strings = ast_strdupa((char *)data);
        if (!strings) {
                ast_log(LOG_ERROR, "Out of memory\n");
index b0c3d1339f8f1f65c0d28b0c004dd174979a8175..970956a3ad23b88d344b73b79ab0b2094e9b7caf 100755 (executable)
@@ -77,22 +77,24 @@ LOCAL_USER_DECL;
 
 static int deltree_exec(struct ast_channel *chan, void *data)
 {
-       int arglen;
        char *argv, *family, *keytree;
+       struct localuser *u;
 
-       arglen = strlen(data);
-       argv = alloca(arglen + 1);
-       if (!argv) {    /* Why would this fail? */
-               ast_log(LOG_DEBUG, "Memory allocation failed\n");
+       LOCAL_USER_ADD(u);
+
+       argv = ast_strdupa(data);
+       if (!argv) {
+               ast_log(LOG_ERROR, "Memory allocation failed\n");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
-       memcpy(argv, data, arglen + 1);
 
        if (strchr(argv, '/')) {
                family = strsep(&argv, "/");
                keytree = strsep(&argv, "\0");
                        if (!family || !keytree) {
                                ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+                               LOCAL_USER_REMOVE(u);
                                return 0;
                        }
                if (!strlen(keytree))
@@ -114,27 +116,31 @@ static int deltree_exec(struct ast_channel *chan, void *data)
                        ast_verbose(VERBOSE_PREFIX_3 "DBdeltree: Error deleting key from database.\n");
        }
 
+       LOCAL_USER_REMOVE(u);
+
        return 0;
 }
 
 static int del_exec(struct ast_channel *chan, void *data)
 {
-       int arglen;
        char *argv, *family, *key;
+       struct localuser *u;
 
-       arglen = strlen(data);
-       argv = alloca(arglen + 1);
-       if (!argv) {    /* Why would this fail? */
-               ast_log (LOG_DEBUG, "Memory allocation failed\n");
+       LOCAL_USER_ADD(u);
+
+       argv = ast_strdupa(data);
+       if (!argv) {
+               ast_log (LOG_ERROR, "Memory allocation failed\n");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
-       memcpy(argv, data, arglen + 1);
 
        if (strchr(argv, '/')) {
                family = strsep(&argv, "/");
                key = strsep(&argv, "\0");
                if (!family || !key) {
                        ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+                       LOCAL_USER_REMOVE(u);
                        return 0;
                }
                if (option_verbose > 2)
@@ -146,27 +152,31 @@ static int del_exec(struct ast_channel *chan, void *data)
        } else {
                ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
        }
+
+       LOCAL_USER_REMOVE(u);
+       
        return 0;
 }
 
 static int put_exec(struct ast_channel *chan, void *data)
 {
-       int arglen;
        char *argv, *value, *family, *key;
        static int dep_warning = 0;
+       struct localuser *u;
+
+       LOCAL_USER_ADD(u);
 
        if (!dep_warning) {
                ast_log(LOG_WARNING, "This application has been deprecated, please use the ${DB(family/key)} function instead.\n");
                dep_warning = 1;
        }
        
-       arglen = strlen(data);
-       argv = alloca(arglen + 1);
-       if (!argv) {    /* Why would this fail? */
-               ast_log(LOG_DEBUG, "Memory allocation failed\n");
+       argv = ast_strdupa(data);
+       if (!argv) {
+               ast_log(LOG_ERROR, "Memory allocation failed\n");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
-       memcpy(argv, data, arglen + 1);
 
        if (strchr(argv, '/') && strchr(argv, '=')) {
                family = strsep(&argv, "/");
@@ -174,6 +184,7 @@ static int put_exec(struct ast_channel *chan, void *data)
                value = strsep(&argv, "\0");
                if (!value || !family || !key) {
                        ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+                       LOCAL_USER_REMOVE(u);
                        return 0;
                }
                if (option_verbose > 2)
@@ -186,28 +197,32 @@ static int put_exec(struct ast_channel *chan, void *data)
        } else  {
                ast_log (LOG_DEBUG, "Ignoring, no parameters\n");
        }
+
+       LOCAL_USER_REMOVE(u);
+
        return 0;
 }
 
 static int get_exec(struct ast_channel *chan, void *data)
 {
-       int arglen;
        char *argv, *varname, *family, *key;
        char dbresult[256];
        static int dep_warning = 0;
+       struct localuser *u;
+
+       LOCAL_USER_ADD(u);
 
        if (!dep_warning) {
                ast_log(LOG_WARNING, "This application has been deprecated, please use the ${DB(family/key)} function instead.\n");
                dep_warning = 1;
        }
        
-       arglen = strlen(data);
-       argv = alloca(arglen + 1);
-       if (!argv) {    /* Why would this fail? */
-               ast_log(LOG_DEBUG, "Memory allocation failed\n");
+       argv = ast_strdupa(data);
+       if (!argv) {
+               ast_log(LOG_ERROR, "Memory allocation failed\n");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
-       memcpy(argv, data, arglen + 1);
 
        if (strchr(argv, '=') && strchr(argv, '/')) {
                varname = strsep(&argv, "=");
@@ -215,6 +230,7 @@ static int get_exec(struct ast_channel *chan, void *data)
                key = strsep(&argv, "\0");
                if (!varname || !family || !key) {
                        ast_log(LOG_DEBUG, "Ignoring; Syntax error in argument\n");
+                       LOCAL_USER_REMOVE(u);
                        return 0;
                }
                if (option_verbose > 2)
@@ -227,13 +243,14 @@ static int get_exec(struct ast_channel *chan, void *data)
                        if (option_verbose > 2)
                        ast_verbose(VERBOSE_PREFIX_3 "DBget: Value not found in database.\n");
                        /* Send the call to n+101 priority, where n is the current priority */
-                       if (ast_exists_extension(chan, chan->context, chan->exten, chan->priority + 101, chan->cid.cid_num))
-                               chan->priority += 100;
+                       ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
                }
-
        } else {
                ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
        }
+
+       LOCAL_USER_REMOVE(u);
+
        return 0;
 }
 
@@ -256,12 +273,10 @@ int load_module(void)
        int retval;
 
        retval = ast_register_application(g_app, get_exec, g_synopsis, g_descrip);
-       if (!retval)
-               retval = ast_register_application(p_app, put_exec, p_synopsis, p_descrip);
-       if (!retval)
-               retval = ast_register_application(d_app, del_exec, d_synopsis, d_descrip);
-       if (!retval)
-               retval = ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip);
+       retval |= ast_register_application(p_app, put_exec, p_synopsis, p_descrip);
+       retval |= ast_register_application(d_app, del_exec, d_synopsis, d_descrip);
+       retval |= ast_register_application(dt_app, deltree_exec, dt_synopsis, dt_descrip);
+       
        return retval;
 }
 
index 7675a917c024dc226ce3f6d7e51b5315573e368f..4d9d05ccf9a73af393fa263fbcde8d22205a3716 100755 (executable)
@@ -692,20 +692,22 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
        char *dblgoto = NULL;
        int priority_jump = 0;
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Dial requires an argument (technology1/number1&technology2/number2...|optional timeout|options)\n");
                return -1;
        }
 
-       if (!(info = ast_strdupa(data))) {
+       LOCAL_USER_ADD(u);
+
+       info = ast_strdupa(data);       
+       if (!info) {
                ast_log(LOG_WARNING, "Unable to dupe data :(\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       LOCAL_USER_ADD(u);
        
        peers = info;
        if (peers) {
-               
                timeout = strchr(info, '|');
                if (timeout) {
                        *timeout = '\0';
@@ -1644,6 +1646,7 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
                        if (res < 0) {
                                ast_log(LOG_WARNING, "Had to drop call because I couldn't make %s compatible with %s\n", chan->name, peer->name);
                                ast_hangup(peer);
+                               LOCAL_USER_REMOVE(u);
                                return -1;
                        }
                        res = ast_bridge_call(chan,peer,&config);
@@ -1674,11 +1677,11 @@ out:
        pbx_builtin_setvar_helper(chan, "DIALSTATUS", status);
        ast_log(LOG_DEBUG, "Exiting with DIALSTATUS=%s.\n", status);
        
-       LOCAL_USER_REMOVE(u);
-       
        if ((ast_test_flag(peerflags, DIAL_GO_ON)) && (!chan->_softhangup) && (res != AST_PBX_KEEPALIVE))
-           res=0;
-           
+               res=0;
+       
+       LOCAL_USER_REMOVE(u);    
+       
        return res;
 }
 
@@ -1693,19 +1696,25 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
 {
        char *announce = NULL, *context = NULL, *dialdata = NULL;
        int sleep = 0, loops = 0, res = 0;
-       struct localuser *u = NULL;
+       struct localuser *u;
        struct ast_flags peerflags;
        
-       memset(&peerflags, 0, sizeof(peerflags));
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "RetryDial requires an argument!\n");
+               return -1;
+       }       
 
        LOCAL_USER_ADD(u);
-       
-       if (!data || !(announce = ast_strdupa(data))) {
+
+       announce = ast_strdupa(data);   
+       if (!announce) {        
                ast_log(LOG_ERROR, "Out of memory!\n");
                LOCAL_USER_REMOVE(u);
                return -1;
        }
        
+       memset(&peerflags, 0, sizeof(peerflags));
+
        if ((dialdata = strchr(announce, '|'))) {
                *dialdata = '\0';
                dialdata++;
index d1b20153232e2a9fdd82b2e4fdb969941092f91e..caa595e4150adecc5ef02c7d4799e8bfff503ca0 100755 (executable)
@@ -98,7 +98,8 @@ static int dictate_exec(struct ast_channel *chan, void *data)
                maxlen = 0,
                mode = 0;
                
-
+       LOCAL_USER_ADD(u);
+       
        snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
        if (data && !ast_strlen_zero(data) && (mydata = ast_strdupa(data))) {
                argc = ast_separate_app_args(mydata, '|', argv, sizeof(argv) / sizeof(argv[0]));
@@ -113,10 +114,10 @@ static int dictate_exec(struct ast_channel *chan, void *data)
        oldr = chan->readformat;
        if ((res = ast_set_read_format(chan, AST_FORMAT_SLINEAR)) < 0) {
                ast_log(LOG_WARNING, "Unable to set to linear mode.\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
        ast_answer(chan);
        ast_safe_sleep(chan, 200);
        for(res = 0; !res;) {
index 66aab01fe44fc2b926165d4f209daa4468e7d784..836d02b42f9503b5fa69f3b7bbb0a9f36bbde614 100755 (executable)
@@ -57,6 +57,13 @@ static int pickup_exec(struct ast_channel *chan, void *data)
        char *tmp = NULL, *exten = NULL, *context = NULL;
        char workspace[256] = "";
 
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "Pickup requires an argument (extension) !\n");
+               return -1;      
+       }
+
+       LOCAL_USER_ADD(u);
+       
        /* Get the extension and context if present */
        exten = data;
        context = strchr(data, '@');
@@ -65,14 +72,6 @@ static int pickup_exec(struct ast_channel *chan, void *data)
                context++;
        }
 
-       /* Make sure we atleast have an extension to work with */
-       if (!exten) {
-               ast_log(LOG_WARNING, "%s requires atleast one argument (extension)\n", app);
-               return -1;
-       }
-
-       LOCAL_USER_ADD(u);
-
        /* Find a channel to pickup */
        origin = ast_get_channel_by_exten_locked(exten, context);
        if (origin) {
@@ -121,7 +120,9 @@ static int pickup_exec(struct ast_channel *chan, void *data)
        }
        /* Done */
  out:
-       if (target) ast_mutex_unlock(&target->lock);
+       if (target) 
+               ast_mutex_unlock(&target->lock);
+       
        LOCAL_USER_REMOVE(u);
 
        return res;
index 1ebd77b1d725af7cd7624700960805a4a4c57934..0385d50baf5ff6bbf9206eb169ed36a19d5aa4f2 100755 (executable)
@@ -410,11 +410,13 @@ static int directory_exec(struct ast_channel *chan, void *data)
        int last = 1;
        char *context, *dialcontext, *dirintro, *options;
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Directory requires an argument (context[,dialcontext])\n");
                return -1;
        }
 
+       LOCAL_USER_ADD(u);
+
        context = ast_strdupa(data);
        dialcontext = strchr(context, '|');
        if (dialcontext) {
@@ -431,10 +433,10 @@ static int directory_exec(struct ast_channel *chan, void *data)
                dialcontext = context;
 
        cfg = realtime_directory(context);
-       if (!cfg)
+       if (!cfg) {
+               LOCAL_USER_REMOVE(u);
                return -1;
-
-       LOCAL_USER_ADD(u);
+       }
 
        dirintro = ast_variable_retrieve(cfg, context, "directoryintro");
        if (!dirintro || ast_strlen_zero(dirintro))
index 20e52283775417470460d9c27d7e50bba0f3e3cb..fc416ca5ce90da85dcfb15e2c5c3dbc87986afd9 100755 (executable)
@@ -120,7 +120,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
        int firstdigittimeout = 20000;
        int digittimeout = 10000;
        struct localuser *u;
-       char tmp[256],arg2[256]="",exten[AST_MAX_EXTENSION],acctcode[20]="";
+       char *tmp, arg2[256]="",exten[AST_MAX_EXTENSION],acctcode[20]="";
        char *ourcontext,*ourcallerid,ourcidname[256],ourcidnum[256],*mailbox;
        struct ast_frame *f;
        struct timeval lastdigittime;
@@ -129,28 +129,39 @@ static int disa_exec(struct ast_channel *chan, void *data)
        FILE *fp;
        char *stringp=NULL;
 
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "disa requires an argument (passcode/passcode file)\n");
+               return -1;
+       }
+
+       LOCAL_USER_ADD(u);
+       
        if (chan->pbx) {
                firstdigittimeout = chan->pbx->rtimeout*1000;
                digittimeout = chan->pbx->dtimeout*1000;
        }
        
-       if (ast_set_write_format(chan,AST_FORMAT_ULAW))
-       {
+       if (ast_set_write_format(chan,AST_FORMAT_ULAW)) {
                ast_log(LOG_WARNING, "Unable to set write format to Mu-law on %s\n",chan->name);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       if (ast_set_read_format(chan,AST_FORMAT_ULAW))
-       {
+       if (ast_set_read_format(chan,AST_FORMAT_ULAW)) {
                ast_log(LOG_WARNING, "Unable to set read format to Mu-law on %s\n",chan->name);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       if (!data || !strlen((char *)data)) {
-               ast_log(LOG_WARNING, "disa requires an argument (passcode/passcode file)\n");
-               return -1;
-       }
+       
        ast_log(LOG_DEBUG, "Digittimeout: %d\n", digittimeout);
        ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
-       strncpy(tmp, (char *)data, sizeof(tmp)-1);
+
+       tmp = ast_strdupa(data);
+       if (!tmp) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }       
+
        stringp=tmp;
        strsep(&stringp, "|");
        ourcontext = strsep(&stringp, "|");
@@ -169,9 +180,8 @@ static int disa_exec(struct ast_channel *chan, void *data)
        if (!mailbox)
                mailbox = "";
        ast_log(LOG_DEBUG, "Mailbox: %s\n",mailbox);
-       LOCAL_USER_ADD(u);
-       if (chan->_state != AST_STATE_UP)
-       {
+       
+       if (chan->_state != AST_STATE_UP) {
                /* answer */
                ast_answer(chan);
        }
@@ -183,8 +193,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
 
        ast_log(LOG_DEBUG, "Context: %s\n",ourcontext);
 
-       if (!strcasecmp(tmp, "no-password"))
-       {;
+       if (!strcasecmp(tmp, "no-password")) {
                k |= 1; /* We have the password */
                ast_log(LOG_DEBUG, "DISA no-password login success\n");
        }
@@ -192,8 +201,7 @@ static int disa_exec(struct ast_channel *chan, void *data)
 
        play_dialtone(chan, mailbox);
 
-       for(;;)
-       {
+       for (;;) {
                  /* if outa time, give em reorder */
                if (ast_tvdiff_ms(ast_tvnow(), lastdigittime) > 
                    ((k&2) ? digittimeout : firstdigittimeout))
index 0a295e9ba001f2693a08401d30deed2536ae10ca..490f12d6061a9f56ac6a6d7f4d0d7c256ff78c4b 100755 (executable)
@@ -138,9 +138,10 @@ static int dumpchan_exec(struct ast_channel *chan, void *data)
        char info[1024];
        int level = 0;
        static char *line = "================================================================================";
+       
        LOCAL_USER_ADD(u);
 
-       if (data) {
+       if (data && !ast_strlen_zero(data)) {
                level = atoi(data);
        }
 
@@ -150,6 +151,7 @@ static int dumpchan_exec(struct ast_channel *chan, void *data)
                ast_verbose("\nDumping Info For Channel: %s:\n%s\nInfo:\n%s\nVariables:\n%s%s\n",chan->name, line, info, vars, line);
 
        LOCAL_USER_REMOVE(u);
+       
        return res;
 }
 
index 48e007977c1bf48069be2e74f15414779e497f97..b59e668633291c7c8357311d63ed20692fd99e65 100755 (executable)
@@ -85,27 +85,27 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
        static int dep_warning=0;
        struct localuser *u;
 
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "EnumLookup requires an argument (extension)\n");
+               return -1;
+       }
+               
        if (!dep_warning) {
                ast_log(LOG_WARNING, "The application EnumLookup is deprecated.  Please use the ENUMLOOKUP() function instead.\n");
-               dep_warning=1;
+               dep_warning = 1;
        }
 
+       LOCAL_USER_ADD(u);
+
        tech[0] = '\0';
 
-       if (!data || ast_strlen_zero(data)) {
-               ast_log(LOG_WARNING, "EnumLookup requires an argument (extension)\n");
-               res = 0;
-       }
-       LOCAL_USER_ADD(u);
-       if (!res) {
-               res = ast_get_enum(chan, data, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL);
-               printf("ENUM got '%d'\n", res);
-       }
-       LOCAL_USER_REMOVE(u);
+       res = ast_get_enum(chan, data, dest, sizeof(dest), tech, sizeof(tech), NULL, NULL);
+       
        if (!res) {     /* Failed to do a lookup */
                /* Look for a "busy" place */
                ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
                pbx_builtin_setvar_helper(chan, "ENUMSTATUS", "ERROR");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
        pbx_builtin_setvar_helper(chan, "ENUMSTATUS", tech);
@@ -167,6 +167,9 @@ static int enumlookup_exec(struct ast_channel *chan, void *data)
                        res = 0;
                }
        }
+
+       LOCAL_USER_REMOVE(u);
+
        return 0;
 }
 
index 0b0f3b28ab7c59e9db772fb4e6cdadc5991193c7..25dcf7fc1ccfbff7d87f2a2aa3afbc56fa96d9e5 100755 (executable)
@@ -64,13 +64,13 @@ static int eval_exec(struct ast_channel *chan, void *data)
        char *s, *newvar=NULL, tmp[MAXRESULT];
        static int dep_warning = 0;
 
+       LOCAL_USER_ADD(u);
+       
        if (!dep_warning) {
                ast_log(LOG_WARNING, "This application has been deprecated in favor of the dialplan function, EVAL\n");
                dep_warning = 1;
        }
 
-       LOCAL_USER_ADD(u);
-
        /* Check and parse arguments */
        if (data) {
                s = ast_strdupa((char *)data);
index e5af548ff3b145357b7638e019d6fb8615efb1a8..06daddcdfd9103574b158cb0021a713f05bae50b 100755 (executable)
@@ -256,6 +256,12 @@ static int app_exec(struct ast_channel *chan, void *data)
        FILE *child_errors = NULL;
        FILE *child_events = NULL;
 
+       LOCAL_USER_ADD(u);
+       
+       AST_LIST_HEAD_INIT(&u->playlist);
+       AST_LIST_HEAD_INIT(&u->finishlist);
+       u->abort_current_sound = 0;
+       
        if (!args || ast_strlen_zero(args)) {
                ast_log(LOG_WARNING, "ExternalIVR requires a command to execute\n");
                goto exit;
@@ -268,8 +274,6 @@ static int app_exec(struct ast_channel *chan, void *data)
        while ((argc < 31) && (argv[argc++] = strsep(&buf, "|")));
        argv[argc] = NULL;
 
-       LOCAL_USER_ADD(u);
-
        if (pipe(child_stdin)) {
                ast_chan_log(LOG_WARNING, chan, "Could not create pipe for child input: %s\n", strerror(errno));
                goto exit;
@@ -285,10 +289,6 @@ static int app_exec(struct ast_channel *chan, void *data)
                goto exit;
        }
 
-       u->abort_current_sound = 0;
-       AST_LIST_HEAD_INIT(&u->playlist);
-       AST_LIST_HEAD_INIT(&u->finishlist);
-
        if (chan->_state != AST_STATE_UP) {
                ast_answer(chan);
        }
@@ -533,12 +533,10 @@ static int app_exec(struct ast_channel *chan, void *data)
        if (child_stderr[1])
                close(child_stderr[1]);
 
-       if (u) {
-               while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list)))
-                       free(entry);
+       while ((entry = AST_LIST_REMOVE_HEAD(&u->playlist, list)))
+               free(entry);
 
-               LOCAL_USER_REMOVE(u);
-       }
+       LOCAL_USER_REMOVE(u);
 
        return res;
 }
index 59b0c5be538b637d6ee5891ec28851c8340e0989..56691ff3d48ef9546450d8d69e4f65d207b592d9 100755 (executable)
@@ -292,13 +292,21 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
        int fdesc = -1;
        char buffer[16384];
        int seekpos = 0;        
-       char data[256] = "";
+       char *data;     
        char *intstr;
-       
        struct ast_config *cfg;
+
+       if (!vdata || ast_strlen_zero(vdata)) {
+               ast_log(LOG_WARNING, "festival requires an argument (text)\n");
+               return -1;
+       }
+
+       LOCAL_USER_ADD(u);
+
        cfg = ast_config_load(FESTIVAL_CONFIG);
        if (!cfg) {
                ast_log(LOG_WARNING, "No such configuration file %s\n", FESTIVAL_CONFIG);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        if (!(host = ast_variable_retrieve(cfg, "general", "host"))) {
@@ -320,19 +328,23 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
        if (!(festivalcommand = ast_variable_retrieve(cfg, "general", "festivalcommand"))) {
                festivalcommand = "(tts_textasterisk \"%s\" 'file)(quit)\n";
        }
-       if (!vdata || ast_strlen_zero(vdata)) {
-               ast_log(LOG_WARNING, "festival requires an argument (text)\n");
+       
+       data = ast_strdupa(vdata);
+       if (!data) {
+               ast_log(LOG_ERROR, "Out of memery\n");
                ast_config_destroy(cfg);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       strncpy(data, vdata, sizeof(data) - 1);
-       if ((intstr = strchr(data, '|'))) {
+
+       intstr = strchr(data, '|');
+       if (intstr) {   
                *intstr = '\0';
                intstr++;
                if (!strcasecmp(intstr, "any"))
                        intstr = AST_DIGIT_ANY;
        }
-       LOCAL_USER_ADD(u);
+       
        ast_log(LOG_DEBUG, "Text passed to festival server : %s\n",(char *)data);
        /* Connect to local festival server */
        
@@ -341,6 +353,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
        if (fd < 0) {
                ast_log(LOG_WARNING,"festival_client: can't get socket\n");
                ast_config_destroy(cfg);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
         memset(&serv_addr, 0, sizeof(serv_addr));
@@ -350,6 +363,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
                if (serverhost == (struct hostent *)0) {
                        ast_log(LOG_WARNING,"festival_client: gethostbyname failed\n");
                        ast_config_destroy(cfg);
+                       LOCAL_USER_REMOVE(u);
                        return -1;
                }
                memmove(&serv_addr.sin_addr,serverhost->h_addr, serverhost->h_length);
@@ -360,6 +374,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
        if (connect(fd, (struct sockaddr *)&serv_addr, sizeof(serv_addr)) != 0) {
                ast_log(LOG_WARNING,"festival_client: connect to server failed\n");
                ast_config_destroy(cfg);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        
@@ -463,7 +478,7 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
        } while (strcmp(ack,"OK\n") != 0);
        close(fd);
        ast_config_destroy(cfg);
-       LOCAL_USER_REMOVE(u);                                                                                
+       LOCAL_USER_REMOVE(u);
        return res;
 
 }
index 493070f42ae6cfc56a63da6e8b2109ee32e2d006..aa9048a0eeb40101903c174de2104ad79296e844 100755 (executable)
@@ -117,13 +117,13 @@ static int group_set_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        static int deprecation_warning = 0;
 
+       LOCAL_USER_ADD(u);
+       
        if (!deprecation_warning) {
                ast_log(LOG_WARNING, "The SetGroup application has been deprecated, please use the GROUP() function.\n");
                deprecation_warning = 1;
        }
 
-       LOCAL_USER_ADD(u);
-
        if (ast_app_group_set_channel(chan, data))
                ast_log(LOG_WARNING, "SetGroup requires an argument (group name)\n");
 
@@ -140,8 +140,6 @@ static int group_check_exec(struct ast_channel *chan, void *data)
        char category[80]="";
        static int deprecation_warning = 0;
 
-       LOCAL_USER_ADD(u);
-
        if (!deprecation_warning) {
                ast_log(LOG_WARNING, "The CheckGroup application has been deprecated, please use a combination of the GotoIf application and the GROUP_COUNT() function.\n");
                deprecation_warning = 1;
@@ -152,6 +150,8 @@ static int group_check_exec(struct ast_channel *chan, void *data)
                return res;
        }
 
+       LOCAL_USER_ADD(u);
+
        ast_app_group_split_group(data, limit, sizeof(limit), category, sizeof(category));
 
        if ((sscanf(limit, "%d", &max) == 1) && (max > -1)) {
index 5d681eb742194b5fdcb3e39c31d0b39492eaf0c1..0115b5bb7839d79034fe72c73d3f5ababd38383b 100755 (executable)
@@ -94,24 +94,25 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
        int vmcount = 0;
        static int dep_warning = 0;
 
+       if (!dep_warning) {
+               ast_log(LOG_WARNING, "The applications HasVoicemail and HasNewVoicemail have been deprecated.  Please use the VMCOUNT() function instead.\n");
+               dep_warning = 1;
+       }
+       
        if (!data) {
                ast_log(LOG_WARNING, "HasVoicemail requires an argument (vm-box[/folder][@context]|varname)\n");
                return -1;
        }
 
-       if (!dep_warning) {
-               ast_log(LOG_WARNING, "The applications HasVoicemail and HasNewVoicemail have been deprecated.  Please use the VMCOUNT() function instead.\n");
-               dep_warning = 1;
-       }
+       LOCAL_USER_ADD(u);
 
        input = ast_strdupa((char *)data);
        if (! input) {
                ast_log(LOG_ERROR, "Out of memory error\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
-
        temps = input;
        if ((temps = strsep(&input, "|"))) {
                if (input && !ast_strlen_zero(input))
@@ -158,11 +159,13 @@ static char *acf_vmcount_exec(struct ast_channel *chan, char *cmd, char *data, c
 
        LOCAL_USER_ACF_ADD(u);
 
+       buf[0] = '\0';
+
        args = ast_strdupa(data);
        if (!args) {
                ast_log(LOG_ERROR, "Out of memory");
                LOCAL_USER_REMOVE(u);
-               return "";
+               return buf;
        }
 
        box = strsep(&args, "|");
@@ -180,7 +183,9 @@ static char *acf_vmcount_exec(struct ast_channel *chan, char *cmd, char *data, c
        }
 
        snprintf(buf, len, "%d", hasvoicemail_internal(context, box, folder));
+
        LOCAL_USER_REMOVE(u);
+       
        return buf;
 }
 
index 1ce63ad9033ee3e4e02a9b5f8341785cc838b1a4..b5803738e3b9e7b7244aaf8fc52ac9f6cb510b65 100755 (executable)
@@ -100,20 +100,24 @@ static int ices_exec(struct ast_channel *chan, void *data)
        struct ast_frame *f;
        char filename[256]="";
        char *c;
-       last.tv_usec = 0;
-       last.tv_sec = 0;
-       if (!data || !strlen(data)) {
+
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "ICES requires an argument (configfile.xml)\n");
                return -1;
        }
+
+       LOCAL_USER_ADD(u);
+       
+       last = ast_tv(0, 0);
+       
        if (pipe(fds)) {
                ast_log(LOG_WARNING, "Unable to create pipe\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        flags = fcntl(fds[1], F_GETFL);
        fcntl(fds[1], F_SETFL, flags | O_NONBLOCK);
        
-       LOCAL_USER_ADD(u);
        ast_stopstream(chan);
 
        if (chan->_state != AST_STATE_UP)
@@ -123,6 +127,7 @@ static int ices_exec(struct ast_channel *chan, void *data)
                close(fds[0]);
                close(fds[1]);
                ast_log(LOG_WARNING, "Answer failed!\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
@@ -132,6 +137,7 @@ static int ices_exec(struct ast_channel *chan, void *data)
                close(fds[0]);
                close(fds[1]);
                ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        if (((char *)data)[0] == '/')
@@ -174,11 +180,14 @@ static int ices_exec(struct ast_channel *chan, void *data)
                }
        }
        close(fds[1]);
-       LOCAL_USER_REMOVE(u);
+       
        if (pid > -1)
                kill(pid, SIGKILL);
        if (!res && oreadformat)
                ast_set_read_format(chan, oreadformat);
+
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index e54c90820a4159963d3dc756aef259082f4b546a..0434eb31039966c96d5f89f97bdd415a957aa1a8 100755 (executable)
@@ -61,14 +61,13 @@ static int sendimage_exec(struct ast_channel *chan, void *data)
        int res = 0;
        struct localuser *u;
        
-       LOCAL_USER_ADD(u);
-
-       if (!data || !strlen((char *)data)) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "SendImage requires an argument (filename)\n");
-               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
+       LOCAL_USER_ADD(u);
+
        if (!ast_supports_images(chan)) {
                /* Does not support transport */
                ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
index 996576b88a2b2055581dec25e527d947434fdef2..e18950be165120043e003d5566817abfe02093d8 100755 (executable)
@@ -157,6 +157,7 @@ static int intercom_exec(struct ast_channel *chan, void *data)
        res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
        if (res < 0) {
                ast_log(LOG_WARNING, "Unable to set format to signed linear on channel %s\n", chan->name);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        /* Read packets from the channel */
@@ -184,9 +185,12 @@ static int intercom_exec(struct ast_channel *chan, void *data)
                                res = -1;
                }
        }
-       LOCAL_USER_REMOVE(u);
+       
        if (!res)
                ast_set_read_format(chan, oreadformat);
+
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index fa28f51a6c7038eea684b91ba1530f4014592178..eb1cb7be0462d4ff20bd50dfdcbebf9396c726c5 100755 (executable)
@@ -88,17 +88,23 @@ static int skel_exec(struct ast_channel *chan, void *data)
 {
        int res=0;
        struct localuser *u;
-       if (!data) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "skel requires an argument (filename)\n");
                return -1;
        }
+       
        LOCAL_USER_ADD(u);
+
        /* Do our thing here */
+
        if (chan->_state != AST_STATE_UP)
                res = ast_answer(chan);
        if (!res)
                res = ast_ivr_menu_run(chan, &ivr_demo, data);
+       
        LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index c63886e9f963b08e19df677580a1092f9839739a..f74d34766ace7f8ecf1d5ce8e78eeaee7b8e8c4f 100755 (executable)
@@ -110,12 +110,14 @@ static int macro_exec(struct ast_channel *chan, void *data)
        char *save_macro_priority;
        char *save_macro_offset;
        struct localuser *u;
-  
        if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Macro() requires arguments. See \"show application macro\" for help.\n");
-               return 0;
+               return -1;
        }
 
+       LOCAL_USER_ADD(u);
+
        /* Count how many levels deep the rabbit hole goes */
        tmp = pbx_builtin_getvar_helper(chan, "MACRO_DEPTH");
        if (tmp) {
@@ -126,16 +128,18 @@ static int macro_exec(struct ast_channel *chan, void *data)
 
        if (depth >= 7) {
                ast_log(LOG_ERROR, "Macro():  possible infinite loop detected.  Returning early.\n");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
        snprintf(depthc, sizeof(depthc), "%d", depth + 1);
        pbx_builtin_setvar_helper(chan, "MACRO_DEPTH", depthc);
 
-       tmp = ast_strdupa((char *) data);
+       tmp = ast_strdupa(data);
        rest = tmp;
        macro = strsep(&rest, "|");
        if (!macro || ast_strlen_zero(macro)) {
                ast_log(LOG_WARNING, "Invalid macro name specified\n");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
        snprintf(fullmacro, sizeof(fullmacro), "macro-%s", macro);
@@ -144,10 +148,10 @@ static int macro_exec(struct ast_channel *chan, void *data)
                        ast_log(LOG_WARNING, "No such context '%s' for macro '%s'\n", fullmacro, macro);
                else
                        ast_log(LOG_WARNING, "Context '%s' for macro '%s' lacks 's' extension, priority 1\n", fullmacro, macro);
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
-
-       LOCAL_USER_ADD(u);
+       
        /* Save old info */
        oldpriority = chan->priority;
        ast_copy_string(oldexten, chan->exten, sizeof(oldexten));
@@ -305,24 +309,33 @@ static int macroif_exec(struct ast_channel *chan, void *data)
 {
        char *expr = NULL, *label_a = NULL, *label_b = NULL;
        int res = 0;
+       struct localuser *u;
 
-       if((expr = ast_strdupa((char *) data))) {
-               if ((label_a = strchr(expr, '?'))) {
-                       *label_a = '\0';
-                       label_a++;
-                       if ((label_b = strchr(label_a, ':'))) {
-                               *label_b = '\0';
-                               label_b++;
-                       }
-                       if (ast_true(expr))
-                               macro_exec(chan, label_a);
-                       else if (label_b) 
-                               macro_exec(chan, label_b);
-                       
-               } else
-                       ast_log(LOG_WARNING, "Invalid Syntax.\n");
-       } else 
+       LOCAL_USER_ADD(u);
+
+       expr = ast_strdupa(data);
+       if (!expr) {
                ast_log(LOG_ERROR, "Out of Memory!\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+
+       if ((label_a = strchr(expr, '?'))) {
+               *label_a = '\0';
+               label_a++;
+               if ((label_b = strchr(label_a, ':'))) {
+                       *label_b = '\0';
+                       label_b++;
+               }
+               if (ast_true(expr))
+                       macro_exec(chan, label_a);
+               else if (label_b) 
+                       macro_exec(chan, label_b);
+       } else
+               ast_log(LOG_WARNING, "Invalid Syntax.\n");
+
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
                        
index 225c929df046ab5e3e2121aac48ad26d6d361390..8f351b519c4bcc730c4128dbaa375412d56bcb23 100755 (executable)
@@ -108,14 +108,19 @@ static int math_exec(struct ast_channel *chan, void *data)
                deprecation_warning = 1;
        }
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "No parameters passed. !\n");
                return -1;
        }
 
        LOCAL_USER_ADD(u);
-               
-       s = ast_strdupa((void *) data);
+
+       s = ast_strdupa(data);
+       if (!s) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
 
        mvar = strsep(&s, "|");
        mvalue1 = strsep(&s, "|");
index 11f59a05f6caf6b2fd3214a7e0a9b981dbf69d25..e5f062235853b2026baf8c0829260bc0801070ca 100755 (executable)
@@ -72,11 +72,13 @@ static int md5_exec(struct ast_channel *chan, void *data)
                dep_warning = 1;
        }       
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Syntax: md5(<varname>=<string>) - missing argument!\n");
                return -1;
        }
+       
        LOCAL_USER_ADD(u);
+
        memset(retvar,0, sizeof(retvar));
        string = ast_strdupa(data);
        varname = strsep(&string,"=");
@@ -107,11 +109,13 @@ static int md5check_exec(struct ast_channel *chan, void *data)
                dep_warning = 1;
        }
        
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Syntax: MD5Check(<md5hash>,<string>) - missing argument!\n");
                return -1;
        }
+       
        LOCAL_USER_ADD(u);
+       
        memset(newhash,0, sizeof(newhash));
 
        string = ast_strdupa(data);
index aa3e6153e3b23533b484b8cae4569e9daa37ff11..4a1edc698d9fdca465ddfd8261389d2654f3bb3e 100755 (executable)
@@ -1667,8 +1667,16 @@ static int count_exec(struct ast_channel *chan, void *data)
                ast_log(LOG_WARNING, "MeetMeCount requires an argument (conference number)\n");
                return -1;
        }
-       localdata = ast_strdupa(data);
+
        LOCAL_USER_ADD(u);
+       
+       localdata = ast_strdupa(data);
+       if (!localdata) {
+               ast_log(LOG_ERROR, "Out of memory!\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+       
        confnum = strsep(&localdata,"|");       
        conf = find_conf(chan, confnum, 0, 0, NULL);
        if (conf)
@@ -1704,17 +1712,19 @@ static int conf_exec(struct ast_channel *chan, void *data)
        int always_prompt = 0;
        char *notdata, *info, *inflags = NULL, *inpin = NULL, the_pin[AST_MAX_EXTENSION] = "";
 
+       LOCAL_USER_ADD(u);
+
        if (!data || ast_strlen_zero(data)) {
                allowretry = 1;
                notdata = "";
        } else {
                notdata = data;
        }
-       LOCAL_USER_ADD(u);
+       
        if (chan->_state != AST_STATE_UP)
                ast_answer(chan);
 
-       info = ast_strdupa((char *)notdata);
+       info = ast_strdupa(notdata);
 
        if (info) {
                char *tmp = strsep(&info, "|");
@@ -1956,6 +1966,9 @@ static int admin_exec(struct ast_channel *chan, void *data) {
        char *params, *command = NULL, *caller = NULL, *conf = NULL;
        struct ast_conference *cnf;
        struct ast_conf_user *user = NULL;
+       struct localuser *u;
+       
+       LOCAL_USER_ADD(u);
 
        ast_mutex_lock(&conflock);
        /* The param has the conference number the user and the command to execute */
@@ -1968,6 +1981,7 @@ static int admin_exec(struct ast_channel *chan, void *data) {
                if (!command) {
                        ast_log(LOG_WARNING, "MeetmeAdmin requires a command!\n");
                        ast_mutex_unlock(&conflock);
+                       LOCAL_USER_REMOVE(u);
                        return -1;
                }
                cnf = confs;
@@ -2059,6 +2073,9 @@ static int admin_exec(struct ast_channel *chan, void *data) {
                }
        }
        ast_mutex_unlock(&conflock);
+
+       LOCAL_USER_REMOVE(u);
+       
        return 0;
 }
 
index 587085dd165de90813be3edbc0a92782d706e720..f520d1a040aa7d43e01c53eb545a994743cd7900 100755 (executable)
@@ -127,6 +127,7 @@ static int milliwatt_exec(struct ast_channel *chan, void *data)
        if (ast_activate_generator(chan,&milliwattgen,"milliwatt") < 0)
        {
                ast_log(LOG_WARNING,"Failed to activate generator on '%s'\n",chan->name);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        while(!ast_safe_sleep(chan, 10000));
index c3893536230b470f4cd3ea32a8f594505c957ddf..a7f8de77cb863856f23394e638f5eb05f4a6ee8a 100755 (executable)
@@ -382,34 +382,36 @@ static int muxmon_exec(struct ast_channel *chan, void *data)
                *filename = NULL,
                *post_process = NULL;
        
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "muxmon requires an argument\n");
                return -1;
        }
 
-       if (!(args = ast_strdupa(data))) {
+       LOCAL_USER_ADD(u);
+
+       args = ast_strdupa(data);       
+       if (!args) {
                ast_log(LOG_WARNING, "Memory Error!\n");
-        return -1;
+               LOCAL_USER_REMOVE(u);
+               return -1;
        }
-       
 
        if ((argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
                filename = argv[0];
-               if ( argc > 1) {
+               if (argc > 1) {
                        options = argv[1];
                }
-               if ( argc > 2) {
+               if (argc > 2) {
                        post_process = argv[2];
                }
        }
        
        if (!filename || ast_strlen_zero(filename)) {
                ast_log(LOG_WARNING, "Muxmon requires an argument (filename)\n");
-        return -1;
+               LOCAL_USER_REMOVE(u);
+               return -1;
        }
 
-       LOCAL_USER_ADD(u);
-
        if (options) {
                char *opts[3] = {};
                ast_parseoptions(muxmon_opts, &flags, opts, options);
@@ -440,13 +442,13 @@ static int muxmon_exec(struct ast_channel *chan, void *data)
                        else {
                                readvol = writevol = minmax(x, 4);
                                x = get_volfactor(readvol);
-                readvol = minmax(x, 16);
+                               readvol = minmax(x, 16);
                                x = get_volfactor(writevol);
-                writevol = minmax(x, 16);
+                               writevol = minmax(x, 16);
                        }
                }
        }
-               pbx_builtin_setvar_helper(chan, "MUXMON_FILENAME", filename);
+       pbx_builtin_setvar_helper(chan, "MUXMON_FILENAME", filename);
        launch_monitor_thread(chan, filename, flags.flags, readvol, writevol, post_process);
 
        LOCAL_USER_REMOVE(u);
index 63f6546b75bc9dceee149d3d2ad2670424b17615..eb1889d0b078ce46d288b7ccf4a810de625af9e1 100755 (executable)
@@ -127,21 +127,27 @@ static int mp3_exec(struct ast_channel *chan, void *data)
                char offset[AST_FRIENDLY_OFFSET];
                short frdata[160];
        } myf;
-       if (!data) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "MP3 Playback requires an argument (filename)\n");
                return -1;
        }
+
+       LOCAL_USER_ADD(u);
+
        if (pipe(fds)) {
                ast_log(LOG_WARNING, "Unable to create pipe\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       LOCAL_USER_ADD(u);
+       
        ast_stopstream(chan);
 
        owriteformat = chan->writeformat;
        res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
        if (res < 0) {
                ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        
@@ -208,11 +214,14 @@ static int mp3_exec(struct ast_channel *chan, void *data)
        }
        close(fds[0]);
        close(fds[1]);
-       LOCAL_USER_REMOVE(u);
+       
        if (pid > -1)
                kill(pid, SIGKILL);
        if (!res && owriteformat)
                ast_set_write_format(chan, owriteformat);
+
+       LOCAL_USER_REMOVE(u);
+       
        return res;
 }
 
index c3893536230b470f4cd3ea32a8f594505c957ddf..a7f8de77cb863856f23394e638f5eb05f4a6ee8a 100755 (executable)
@@ -382,34 +382,36 @@ static int muxmon_exec(struct ast_channel *chan, void *data)
                *filename = NULL,
                *post_process = NULL;
        
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "muxmon requires an argument\n");
                return -1;
        }
 
-       if (!(args = ast_strdupa(data))) {
+       LOCAL_USER_ADD(u);
+
+       args = ast_strdupa(data);       
+       if (!args) {
                ast_log(LOG_WARNING, "Memory Error!\n");
-        return -1;
+               LOCAL_USER_REMOVE(u);
+               return -1;
        }
-       
 
        if ((argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
                filename = argv[0];
-               if ( argc > 1) {
+               if (argc > 1) {
                        options = argv[1];
                }
-               if ( argc > 2) {
+               if (argc > 2) {
                        post_process = argv[2];
                }
        }
        
        if (!filename || ast_strlen_zero(filename)) {
                ast_log(LOG_WARNING, "Muxmon requires an argument (filename)\n");
-        return -1;
+               LOCAL_USER_REMOVE(u);
+               return -1;
        }
 
-       LOCAL_USER_ADD(u);
-
        if (options) {
                char *opts[3] = {};
                ast_parseoptions(muxmon_opts, &flags, opts, options);
@@ -440,13 +442,13 @@ static int muxmon_exec(struct ast_channel *chan, void *data)
                        else {
                                readvol = writevol = minmax(x, 4);
                                x = get_volfactor(readvol);
-                readvol = minmax(x, 16);
+                               readvol = minmax(x, 16);
                                x = get_volfactor(writevol);
-                writevol = minmax(x, 16);
+                               writevol = minmax(x, 16);
                        }
                }
        }
-               pbx_builtin_setvar_helper(chan, "MUXMON_FILENAME", filename);
+       pbx_builtin_setvar_helper(chan, "MUXMON_FILENAME", filename);
        launch_monitor_thread(chan, filename, flags.flags, readvol, writevol, post_process);
 
        LOCAL_USER_REMOVE(u);
index 515806941b558be806a48b56b34469f8aa02ec5d..150744bcc84da65f2b826da8b77215da3a5aac73 100755 (executable)
@@ -117,17 +117,22 @@ static int NBScat_exec(struct ast_channel *chan, void *data)
                char offset[AST_FRIENDLY_OFFSET];
                short frdata[160];
        } myf;
+       
+       LOCAL_USER_ADD(u);
+
        if (socketpair(AF_LOCAL, SOCK_STREAM, 0, fds)) {
                ast_log(LOG_WARNING, "Unable to create socketpair\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       LOCAL_USER_ADD(u);
+       
        ast_stopstream(chan);
 
        owriteformat = chan->writeformat;
        res = ast_set_write_format(chan, AST_FORMAT_SLINEAR);
        if (res < 0) {
                ast_log(LOG_WARNING, "Unable to set write format to signed linear\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        
@@ -191,11 +196,14 @@ static int NBScat_exec(struct ast_channel *chan, void *data)
        }
        close(fds[0]);
        close(fds[1]);
-       LOCAL_USER_REMOVE(u);
+       
        if (pid > -1)
                kill(pid, SIGKILL);
        if (!res && owriteformat)
                ast_set_write_format(chan, owriteformat);
+
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index d141ae14e4e14e23414a231282e32a9096ed384b..a27f4d0c241298f36e9e46090c8a311ea6d6f7ee 100755 (executable)
@@ -109,10 +109,21 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
        char *temp;
        char *provider, *opts=NULL;
        struct ast_osp_result result;
-       if (!data || ast_strlen_zero(data) || !(temp = ast_strdupa(data))) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "OSPLookup requires an argument (extension)\n");
                return -1;
        }
+
+       LOCAL_USER_ADD(u);
+
+       temp = ast_strdupa(data);
+       if (!temp) {
+               ast_log(LOG_ERROR, "Out of memory!\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+
        provider = strchr(temp, '|');
        if (provider) {
                *provider = '\0';
@@ -123,7 +134,7 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
                        opts++;
                }
        }
-       LOCAL_USER_ADD(u);
+       
        ast_log(LOG_DEBUG, "Whoo hoo, looking up OSP on '%s' via '%s'\n", temp, provider ? provider : "<default>");
        if ((res = ast_osp_lookup(chan, provider, temp, chan->cid.cid_num, &result)) > 0) {
                char tmp[80];
@@ -157,10 +168,14 @@ static int ospnext_exec(struct ast_channel *chan, void *data)
        char *temp;
        int cause;
        struct ast_osp_result result;
+
        if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "OSPNext should have an argument (cause)\n");
+               return -1;
        }
+       
        LOCAL_USER_ADD(u);
+
        cause = str2cause((char *)data);
        temp = pbx_builtin_getvar_helper(chan, "OSPHANDLE");
        result.handle = -1;
@@ -201,9 +216,14 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
        int cause;
        time_t start=0, duration=0;
        struct ast_osp_result result;
+
        if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "OSPFinish should have an argument (cause)\n");
+               return -1;
        }
+
+       LOCAL_USER_ADD(u);      
+
        if (chan->cdr) {
                start = chan->cdr->answer.tv_sec;
                if (start)
@@ -212,7 +232,7 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
                        duration = 0;
        } else
                ast_log(LOG_WARNING, "OSPFinish called on channel '%s' with no CDR!\n", chan->name);
-       LOCAL_USER_ADD(u);
+       
        cause = str2cause((char *)data);
        temp = pbx_builtin_getvar_helper(chan, "OSPHANDLE");
        result.handle = -1;
index 6f6463e201fd312dcea652cd0add348cd0df3c5d..2e3d0e1e5c7c8e0e3e3ef80db5652e9bfb4ed163 100755 (executable)
@@ -120,25 +120,25 @@ static int page_exec(struct ast_channel *chan, void *data)
        char *tmp;
        int res=0;
 
-       if (!data)
-               return -1;
-
-       if (ast_strlen_zero(data)) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "This application requires at least one argument (destination(s) to page)\n");
                return -1;
        }
 
+       LOCAL_USER_ADD(u);
+
        if (!(app = pbx_findapp("MeetMe"))) {
                ast_log(LOG_WARNING, "There is no MeetMe application available!\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        };
 
-       if (!(options = ast_strdupa((char *) data))) {
+       options = ast_strdupa(data);
+       if (!options) {
                ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-               
-       LOCAL_USER_ADD(u);
 
        tmp = strsep(&options, "|");
        if (options)
index ff49e80c6a42c667661d9185173d7ee402ab10ef..3524b5cacaad848bdf44768aa496f4762fb9a739 100755 (executable)
@@ -80,15 +80,19 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
        int outstate;
 
        struct localuser *u;
-       if(!data || (data && !strlen(data))) {
+
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "ParkAndAnnounce requires arguments: (announce:template|timeout|dial|[return_context])\n");
                return -1;
        }
   
+       LOCAL_USER_ADD(u);
+
        l=strlen(data)+2;
        orig_s=malloc(l);
        if(!orig_s) {
                ast_log(LOG_WARNING, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        s=orig_s;
@@ -98,6 +102,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
        if(! template) {
                ast_log(LOG_WARNING, "PARK: An announce template must be defined\n");
                free(orig_s);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
   
@@ -109,6 +114,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
        if(!dial) {
                ast_log(LOG_WARNING, "PARK: A dial resource must be specified i.e: Console/dsp or Zap/g1/5551212\n");
                free(orig_s);
+               LOCAL_USER_REMOVE(u);
                return -1;
        } else {
                dialtech=strsep(&dial, "/");
@@ -141,6 +147,7 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
        if(atoi(priority) < 0) {
                ast_log(LOG_WARNING, "Priority '%s' must be a number > 0\n", priority);
                free(orig_s);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        /* At this point we have a priority and maybe an extension and a context */
@@ -153,7 +160,6 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
                chan->priority++;
        }
 
-
        if(option_verbose > 2) {
                ast_verbose( VERBOSE_PREFIX_3 "Return Context: (%s,%s,%d) ID: %s\n", chan->context,chan->exten, chan->priority, chan->cid.cid_num);
                if(!ast_exists_extension(chan, chan->context, chan->exten, chan->priority, chan->cid.cid_num)) {
@@ -161,8 +167,6 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
                }
        }
   
-       LOCAL_USER_ADD(u);
-
        /* we are using masq_park here to protect * from touching the channel once we park it.  If the channel comes out of timeout
        before we are done announcing and the channel is messed with, Kablooeee.  So we use Masq to prevent this.  */
 
@@ -228,9 +232,10 @@ static int parkandannounce_exec(struct ast_channel *chan, void *data)
 
        ast_stopstream(dchan);  
        ast_hangup(dchan);
-
-       LOCAL_USER_REMOVE(u);
        free(orig_s);
+       
+       LOCAL_USER_REMOVE(u);
+       
        return res;
 }
 
index 66f4fd05f54f31c6040110036978b1f778296cfd..62f647eb020a9f2623797553d1f1c7970b79d910 100755 (executable)
@@ -69,10 +69,21 @@ static int playback_exec(struct ast_channel *chan, void *data)
        int option_noanswer = 0;
        char *stringp = NULL;
        char *front = NULL, *back = NULL;
-       if (!data || ast_strlen_zero((char *)data) || !(tmp = ast_strdupa(data))) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Playback requires an argument (filename)\n");
                return -1;
        }
+
+       LOCAL_USER_ADD(u);
+
+       tmp = ast_strdupa(data);
+       if (!tmp) {
+               ast_log(LOG_ERROR, "Out of memory!\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;      
+       }
+
        stringp = tmp;
        strsep(&stringp, "|");
        options = strsep(&stringp, "|");
@@ -80,7 +91,7 @@ static int playback_exec(struct ast_channel *chan, void *data)
                option_skip = 1;
        if (options && !strcasecmp(options, "noanswer"))
                option_noanswer = 1;
-       LOCAL_USER_ADD(u);
+       
        if (chan->_state != AST_STATE_UP) {
                if (option_skip) {
                        /* At the user's option, skip if the line is not up */
index 27d73ca71c6642a357dc8369c7956e3857c55b01..35558fd881448f00ae604683e926877012851a25 100755 (executable)
@@ -2556,25 +2556,27 @@ static int pqm_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        char *queuename, *interface;
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "PauseQueueMember requires an argument ([queuename]|interface])\n");
                return -1;
        }
 
+       LOCAL_USER_ADD(u);
+
        queuename = ast_strdupa((char *)data);
        if (!queuename) {
                ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
        interface = strchr(queuename, '|');
        if (!interface) {
                ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename]|interface])\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
-
        *interface = '\0';
        interface++;
 
@@ -2584,6 +2586,7 @@ static int pqm_exec(struct ast_channel *chan, void *data)
                        LOCAL_USER_REMOVE(u);
                        return 0;
                }
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
@@ -2597,25 +2600,27 @@ static int upqm_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        char *queuename, *interface;
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "UnpauseQueueMember requires an argument ([queuename]|interface])\n");
                return -1;
        }
 
+       LOCAL_USER_ADD(u);
+
        queuename = ast_strdupa((char *)data);
        if (!queuename) {
                ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
        interface = strchr(queuename, '|');
        if (!interface) {
                ast_log(LOG_WARNING, "Missing interface argument to PauseQueueMember ([queuename]|interface])\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
-
        *interface = '\0';
        interface++;
 
@@ -2625,6 +2630,7 @@ static int upqm_exec(struct ast_channel *chan, void *data)
                        LOCAL_USER_REMOVE(u);
                        return 0;
                }
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
@@ -2641,19 +2647,20 @@ static int rqm_exec(struct ast_channel *chan, void *data)
        char tmpchan[256]="";
        char *interface = NULL;
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "RemoveQueueMember requires an argument (queuename[|interface])\n");
                return -1;
        }
 
-       info = ast_strdupa((char *)data);
+       LOCAL_USER_ADD(u);
+
+       info = ast_strdupa(data);
        if (!info) {
                ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
-
        queuename = info;
        if (queuename) {
                interface = strchr(queuename, '|');
@@ -2704,17 +2711,19 @@ static int aqm_exec(struct ast_channel *chan, void *data)
        char *penaltys=NULL;
        int penalty = 0;
 
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "AddQueueMember requires an argument (queuename[|[interface][|penalty]])\n");
                return -1;
        }
 
-       info = ast_strdupa((char *)data);
+       LOCAL_USER_ADD(u);
+
+       info = ast_strdupa(data);
        if (!info) {
                ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       LOCAL_USER_ADD(u);
 
        queuename = info;
        if (queuename) {
@@ -2794,7 +2803,7 @@ static int queue_exec(struct ast_channel *chan, void *data)
                ast_log(LOG_WARNING, "Queue requires an argument: queuename[|options[|URL][|announceoverride][|timeout]]\n");
                return -1;
        }
-       
+
        LOCAL_USER_ADD(u);
 
        /* Setup our queue entry */
@@ -3024,12 +3033,15 @@ static char *queue_function_qac(struct ast_channel *chan, char *cmd, char *data,
        struct localuser *u;
        struct member *m;
 
+       LOCAL_USER_ACF_ADD(u);
+
+       ast_copy_string(buf, "0", len);
+       
        if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_ERROR, "QUEUEAGENTCOUNT requires an argument: queuename\n");
-               return "0";
+               LOCAL_USER_REMOVE(u);
+               return buf;
        }
-       
-       LOCAL_USER_ACF_ADD(u);
 
        ast_mutex_lock(&qlock);
 
index bbd1e0c1193c1d223cb64aca3e60a54a4db55daf..80c2f9949ddb655af9cd27d67b3662de73f9a60d 100755 (executable)
@@ -61,13 +61,20 @@ static int random_exec(struct ast_channel *chan, void *data)
        char *s;
        char *prob;
        int probint;
-
-       if (!data) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "Random requires an argument ([probability]:[[context|]extension|]priority)\n");
                return -1;
        }
+       
        LOCAL_USER_ADD(u);
-       s = ast_strdupa((void *) data);
+
+       s = ast_strdupa(data);
+       if (!s) {
+               ast_log(LOG_ERROR, "Out of memory!\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
 
        prob = strsep(&s,":");
        if ((!prob) || (sscanf(prob, "%d", &probint) != 1))
index 4fd6401124b5337efe211405495a13e6b9b40151..79b075b289e91ccd92a8165215c8f11d5427c96d 100755 (executable)
@@ -89,11 +89,23 @@ static int read_exec(struct ast_channel *chan, void *data)
        char *argcopy = NULL;
        char *args[8];
 
-       if (data)
-               argcopy = ast_strdupa((char *)data);
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "Read requires an argument (variable)\n");
+               return -1;
+       }
+
+       LOCAL_USER_ADD(u);
+       
+       argcopy = ast_strdupa(data);
+       if (!argcopy) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
 
        if (ast_separate_app_args(argcopy, '|', args, sizeof(args) / sizeof(args[0])) < 1) {
-               ast_log(LOG_WARNING, "Cannot Parse Arguements.\n");
+               ast_log(LOG_WARNING, "Cannot Parse Arguments.\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
@@ -142,9 +154,10 @@ static int read_exec(struct ast_channel *chan, void *data)
        }
        if (!(varname) || ast_strlen_zero(varname)) {
                ast_log(LOG_WARNING, "Invalid! Usage: Read(variable[|filename][|maxdigits][|option][|attempts][|timeout])\n\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
-       LOCAL_USER_ADD(u);
+       
        if (chan->_state != AST_STATE_UP) {
                if (option_skip) {
                        /* At the user's option, skip if the line is not up */
index 537786f0416bce848c04e793b428818599e5f977..d08041f4e43ea1fbd6fb434dd3620bf352641a2f 100755 (executable)
@@ -63,10 +63,17 @@ static int readfile_exec(struct ast_channel *chan, void *data)
        char *s, *varname=NULL, *file=NULL, *length=NULL, *returnvar=NULL;
        int len=0;
 
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "ReadFile require an argument!\n");
+               return -1;
+       }
+
+       LOCAL_USER_ADD(u);
 
        s = ast_strdupa(data);
        if (!s) {
                ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
@@ -76,18 +83,17 @@ static int readfile_exec(struct ast_channel *chan, void *data)
 
        if (!varname || !file) {
                ast_log(LOG_ERROR, "No file or variable specified!\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
-       LOCAL_USER_ADD(u);
        if (length) {
                if ((sscanf(length, "%d", &len) != 1) || (len < 0)) {
                        ast_log(LOG_WARNING, "%s is not a positive number, defaulting length to max\n", length);
                        len = 0;
                }
        }
-       
-       
+
        returnvar = ast_read_textfile(file);
        if(len > 0){
                if(len < strlen(returnvar))
index 4e2883228d388360aa472b1797fbcaeb66d67610..2a883d0710056d7742eeb5a124659ea34af63a85 100755 (executable)
@@ -129,11 +129,14 @@ static int realtime_update_exec(struct ast_channel *chan, void *data)
        char *family=NULL, *colmatch=NULL, *value=NULL, *newcol=NULL, *newval=NULL;
        struct localuser *u;
        int res = 0;
-       if (!data) {
-        ast_log(LOG_ERROR,"Invalid input %s\n",UUSAGE);
-        return -1;
-    }
+
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_ERROR,"Invalid input: usage %s\n",UUSAGE);
+               return -1;
+       }
+       
        LOCAL_USER_ADD(u);
+
        if ((family = ast_strdupa(data))) {
                if ((colmatch = strchr(family,'|'))) {
                        crop_data(colmatch);
@@ -155,8 +158,8 @@ static int realtime_update_exec(struct ast_channel *chan, void *data)
        }
 
        LOCAL_USER_REMOVE(u);
+       
        return res;
-
 }
 
 
@@ -167,12 +170,14 @@ static int realtime_exec(struct ast_channel *chan, void *data)
        struct ast_variable *var, *itt;
        char *family=NULL, *colmatch=NULL, *value=NULL, *prefix=NULL, *vname=NULL;
        size_t len;
-
-       if (!data) {
+               
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_ERROR,"Invalid input: usage %s\n",USAGE);
                return -1;
        }
+       
        LOCAL_USER_ADD(u);
+
        if ((family = ast_strdupa(data))) {
                if ((colmatch = strchr(family,'|'))) {
                        crop_data(colmatch);
index 7b8e145128b6a584ab4629fe30d061ed2dcdded0..4186e729a16407412f1555cf3b3ba12a7e95de8a 100755 (executable)
@@ -99,18 +99,23 @@ static int record_exec(struct ast_channel *chan, void *data)
        int rfmt = 0;
        int flags;
        
-
-
-
        /* The next few lines of code parse out the filename and header from the input string */
        if (!data || ast_strlen_zero(data)) { /* no data implies no filename or anything is present */
                ast_log(LOG_WARNING, "Record requires an argument (filename)\n");
                return -1;
        }
+
+       LOCAL_USER_ADD(u);
+
        /* Yay for strsep being easy */
        vdata = ast_strdupa(data);
+       if (!vdata) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+
        p = vdata;
-       
        filename = strsep(&p, "|");
        silstr = strsep(&p, "|");
        maxstr = strsep(&p, "|");       
@@ -129,6 +134,7 @@ static int record_exec(struct ast_channel *chan, void *data)
        }
        if (!ext) {
                ast_log(LOG_WARNING, "No extension specified to filename!\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
        if (silstr) {
@@ -180,7 +186,7 @@ static int record_exec(struct ast_channel *chan, void *data)
                strncpy(tmp, filename, sizeof(tmp)-1);
        /* end of routine mentioned */
        
-       LOCAL_USER_ADD(u);
+       
        
        if (chan->_state != AST_STATE_UP) {
                if (option_skip) {
@@ -213,11 +219,13 @@ static int record_exec(struct ast_channel *chan, void *data)
                        res = ast_set_read_format(chan, AST_FORMAT_SLINEAR);
                        if (res < 0) {
                                ast_log(LOG_WARNING, "Unable to set to linear mode, giving up\n");
+                               LOCAL_USER_REMOVE(u);
                                return -1;
                        }
                        sildet = ast_dsp_new();
                        if (!sildet) {
                                ast_log(LOG_WARNING, "Unable to create silence detector :(\n");
+                               LOCAL_USER_REMOVE(u);
                                return -1;
                        }
                        ast_dsp_set_threshold(sildet, 256);
@@ -308,7 +316,6 @@ static int record_exec(struct ast_channel *chan, void *data)
        } else
                ast_log(LOG_WARNING, "Could not answer channel '%s'\n", chan->name);
        
-       LOCAL_USER_REMOVE(u);
        if ((silence > 0) && rfmt) {
                res = ast_set_read_format(chan, rfmt);
                if (res)
@@ -316,6 +323,9 @@ static int record_exec(struct ast_channel *chan, void *data)
                if (sildet)
                        ast_dsp_free(sildet);
        }
+
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index 79001accaf6c9da8beb6f378309c3d9fbfc32581..e42f065877876046bf3d61f041b57964576d360a 100755 (executable)
@@ -62,21 +62,33 @@ static int senddtmf_exec(struct ast_channel *chan, void *data)
        char *digits = NULL, *to = NULL;
        int timeout = 250;
 
-       if (data && !ast_strlen_zero(data) && (digits = ast_strdupa((char *)data))) {
-               if((to = strchr(digits,'|'))) {
-                       *to = '\0';
-                       to++;
-                       timeout = atoi(to);
-               }
-               LOCAL_USER_ADD(u);
-               if(timeout <= 0)
-                       timeout = 250;
-
-               res = ast_dtmf_stream(chan,NULL,digits,timeout);
-               LOCAL_USER_REMOVE(u);
-       } else {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "SendDTMF requires an argument (digits or *#aAbBcCdD)\n");
+               return 0;
+       }
+
+       LOCAL_USER_ADD(u);
+
+       digits = ast_strdupa(data);
+       if (!digits) {
+               ast_log(LOG_ERROR, "Out of Memory!\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
        }
+
+       if ((to = strchr(digits,'|'))) {
+               *to = '\0';
+               to++;
+               timeout = atoi(to);
+       }
+               
+       if(timeout <= 0)
+               timeout = 250;
+
+       res = ast_dtmf_stream(chan,NULL,digits,timeout);
+               
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index c33561af2636ceb78951683b0bfaef40a6d94e02..bbc58b14adb9e1b23fde6c4f4363ea564572760c 100755 (executable)
@@ -70,13 +70,14 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
        int res = 0;
        struct localuser *u;
        char *status = "UNSUPPORTED";
-
-       if (!data || !strlen((char *)data)) {
+               
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "SendText requires an argument (text)\n");
                return -1;
        }
-
+       
        LOCAL_USER_ADD(u);
+
        ast_mutex_lock(&chan->lock);
        if (!chan->tech->send_text) {
                ast_mutex_unlock(&chan->lock);
index 4fd381fe56b1f7d0105d7acd02356986020b16d9..fec0ad605b66089d3dc365ed32b5ab7de0571939 100755 (executable)
@@ -68,15 +68,17 @@ static int setcallerid_pres_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        int pres = -1;
 
+       LOCAL_USER_ADD(u);
+       
        pres = ast_parse_caller_presentation(data);
 
        if (pres < 0) {
                ast_log(LOG_WARNING, "'%s' is not a valid presentation (see 'show application SetCallerPres')\n",
                        (char *) data);
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
-
-       LOCAL_USER_ADD(u);
+       
        chan->cid.cid_pres = pres;
        LOCAL_USER_REMOVE(u);
        return 0;
@@ -97,14 +99,27 @@ static char *descrip =
 static int setcallerid_exec(struct ast_channel *chan, void *data)
 {
        int res = 0;
-       char tmp[256] = "";
+       char *tmp = NULL;
        char name[256];
        char num[256];
        struct localuser *u;
        char *opt;
        int anitoo = 0;
-       if (data)
-               ast_copy_string(tmp, (char *)data, sizeof(tmp));
+
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_WARNING, "SetCallerID requires an argument!\n");
+               return 0;
+       }
+       
+       LOCAL_USER_ADD(u);
+       
+       tmp = ast_strdupa(data);
+       if (!tmp) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+       
        opt = strchr(tmp, '|');
        if (opt) {
                *opt = '\0';
@@ -112,10 +127,12 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
                if (*opt == 'a')
                        anitoo = 1;
        }
-       LOCAL_USER_ADD(u);
+       
        ast_callerid_split(tmp, name, sizeof(name), num, sizeof(num));
        ast_set_callerid(chan, num, name, anitoo ? num : NULL);
+
        LOCAL_USER_REMOVE(u);
+       
        return res;
 }
 
index 143ca73e0b09eb14553bd49f65772159d079c032..98a265ff3526fe7c7319319d1f42fe86b65643d0 100755 (executable)
@@ -111,9 +111,9 @@ static int setcdruserfield_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        int res = 0;
        
-       LOCAL_USER_ADD(u)
-       if (chan->cdr && data) 
-       {
+       LOCAL_USER_ADD(u);
+
+       if (chan->cdr && data) {
                ast_cdr_setuserfield(chan, (char*)data);
        }
 
@@ -127,9 +127,9 @@ static int appendcdruserfield_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        int res = 0;
        
-       LOCAL_USER_ADD(u)
-       if (chan->cdr && data) 
-       {
+       LOCAL_USER_ADD(u);
+
+       if (chan->cdr && data) {
                ast_cdr_appenduserfield(chan, (char*)data);
        }
 
index 019adeb8087cd425bd1adaa0a863a096c556556b..8621e91e1988aecfcef25814cb56d46e5f2acca8 100755 (executable)
@@ -60,8 +60,7 @@ LOCAL_USER_DECL;
 
 static int setcallerid_exec(struct ast_channel *chan, void *data)
 {
-       int res = 0;
-       char tmp[256] = "";
+       char *tmp = NULL;       
        struct localuser *u;
        char *opt;
        static int deprecation_warning = 0;
@@ -71,16 +70,30 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
                deprecation_warning = 1;
        }
 
-       if (data)
-               ast_copy_string(tmp, (char *)data, sizeof(tmp));
+       if (!data || ast_strlen_zero(data)) {
+               ast_log(LOG_ERROR, "SetCIDName requires an argument!\n");
+               return 0;       
+       }
+
+       LOCAL_USER_ADD(u);
+
+       tmp = ast_strdupa(data);
+       if (!tmp) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+       
        opt = strchr(tmp, '|');
        if (opt) {
                *opt = '\0';
        }
-       LOCAL_USER_ADD(u);
+       
        ast_set_callerid(chan, NULL, tmp, NULL);
+
        LOCAL_USER_REMOVE(u);
-       return res;
+       
+       return 0;
 }
 
 int unload_module(void)
index 07a064bb4b6567f987621830cd9b5f5a8bfdc32f..cd94f7555edaa2d1fe63237927c5c7b1a1353437 100755 (executable)
@@ -65,16 +65,21 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        char *opt;
        int anitoo = 0;
-       char tmp[256];
+       char *tmp = NULL;
        static int deprecation_warning = 0;
 
+       LOCAL_USER_ADD(u);
+       
        if (!deprecation_warning) {
                ast_log(LOG_WARNING, "SetCIDNum is deprecated, please use Set(CALLERID(number)=value) instead.\n");
                deprecation_warning = 1;
        }
 
        if (data)
-               ast_copy_string(tmp, (char *)data, sizeof(tmp));
+               tmp = ast_strdupa(data);
+       else
+               tmp = "";
+       
        opt = strchr(tmp, '|');
        if (opt) {
                *opt = '\0';
@@ -82,9 +87,11 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
                if (*opt == 'a')
                        anitoo = 1;
        }
-       LOCAL_USER_ADD(u);
+       
        ast_set_callerid(chan, tmp, NULL, anitoo ? tmp : NULL);
+
        LOCAL_USER_REMOVE(u);
+       
        return res;
 }
 
index c0f155f20ecc00d6e664336e948a8f13dd83e4a2..faff3efb501e0de5a1a8516e88f090b3c99b9ddd 100755 (executable)
@@ -61,22 +61,25 @@ static int setrdnis_exec(struct ast_channel *chan, void *data)
 {
        struct localuser *u;
        char *opt, *n, *l;
-       char tmp[256];
+       char *tmp = NULL;
        static int deprecation_warning = 0;
 
+       LOCAL_USER_ADD(u);
+       
        if (!deprecation_warning) {
                ast_log(LOG_WARNING, "SetRDNIS is deprecated, please use Set(CALLERID(rdnis)=value) instead.\n");
                deprecation_warning = 1;
        }
 
        if (data)
-               ast_copy_string(tmp, (char *)data, sizeof(tmp));
+               tmp = ast_strdupa(data);
        else
-               tmp[0] = '\0';
+               tmp = "";       
+
        opt = strchr(tmp, '|');
        if (opt)
                *opt = '\0';
-       LOCAL_USER_ADD(u);
+       
        n = l = NULL;
        ast_callerid_parse(tmp, &n, &l);
        if (l) {
@@ -87,7 +90,9 @@ static int setrdnis_exec(struct ast_channel *chan, void *data)
                chan->cid.cid_rdnis = (l[0]) ? strdup(l) : NULL;
                ast_mutex_unlock(&chan->lock);
        }
+
        LOCAL_USER_REMOVE(u);
+       
        return 0;
 }
 
index 1b055337719641cbd869ce885d0ddfdc60925f72..461c5fc99767e314ea4588735e30f0b98aca7ef3 100755 (executable)
@@ -70,18 +70,24 @@ static char *descrip =
 
 static int settransfercapability_exec(struct ast_channel *chan, void *data)
 {
-       char tmp[256] = "";
+       char *tmp = NULL;
        struct localuser *u;
        int x;
        char *opts;
        int transfercapability = -1;
        
+       LOCAL_USER_ADD(u);
+       
        if (data)
-               ast_copy_string(tmp, (char *)data, sizeof(tmp));
+               tmp = ast_strdupa(data);
+       else
+               tmp = "";
+
        opts = strchr(tmp, '|');
        if (opts)
                *opts = '\0';
-       for (x=0;x<sizeof(transcaps) / sizeof(transcaps[0]);x++) {
+       
+       for (x = 0; x < (sizeof(transcaps) / sizeof(transcaps[0])); x++) {
                if (!strcasecmp(transcaps[x].name, tmp)) {
                        transfercapability = transcaps[x].val;
                        break;
@@ -89,15 +95,18 @@ static int settransfercapability_exec(struct ast_channel *chan, void *data)
        }
        if (transfercapability < 0) {
                ast_log(LOG_WARNING, "'%s' is not a valid transfer capability (see 'show application SetTransferCapability')\n", tmp);
-               return 0;
-       } else {
-               LOCAL_USER_ADD(u);
-               chan->transfercapability = (unsigned short)transfercapability;
                LOCAL_USER_REMOVE(u);
-               if (option_verbose > 2)
-                       ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);                        
                return 0;
        }
+               
+       chan->transfercapability = (unsigned short)transfercapability;
+       
+       if (option_verbose > 2)
+               ast_verbose(VERBOSE_PREFIX_3 "Setting transfer capability to: 0x%.2x - %s.\n", transfercapability, tmp);                        
+       
+       LOCAL_USER_REMOVE(u);
+
+       return 0;
 }
 
 
index 15817444f21825f5e65b739813d15ea9e00328f5..825dd1927d1d5de5e2e54cd384f4d92fc84d0a26 100755 (executable)
@@ -72,17 +72,24 @@ static int app_exec(struct ast_channel *chan, void *data)
        char *opts[2];
        char *argv[2];
 
-       if (!(args = ast_strdupa((char *)data))) {
-               ast_log(LOG_ERROR, "Out of memory!\n");
-               return -1;
-       }
-
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "%s requires an argument (dummy|[options])\n",app);
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
        LOCAL_USER_ADD(u);
+       
+       /* Do our thing here */
+
+       /* We need to make a copy of the input string if we are going to modify it! */
+       args = ast_strdupa(data);       
+       if (!args) {
+               ast_log(LOG_ERROR, "Out of memory!\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+       
        if ((argc = ast_separate_app_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
                dummy = argv[0];
                options = argv[1];
@@ -101,8 +108,8 @@ static int app_exec(struct ast_channel *chan, void *data)
        if (ast_test_flag(&flags, OPTION_C))
                ast_log(LOG_NOTICE,"Option C is set with : %s\n", opts[1] ? opts[1] : "<unspecified>");
 
-       /* Do our thing here */
        LOCAL_USER_REMOVE(u);
+       
        return res;
 }
 
index 80ad3ddb09007bf7af4e83e40ddf7c94b0adf05d..77774f20b3729b87914a6cf304a9da5861535a0a 100755 (executable)
@@ -1363,10 +1363,14 @@ static int sms_exec (struct ast_channel *chan, void *data)
        struct localuser *u;
        struct ast_frame *f;
        sms_t h = { 0 };
+       
+       LOCAL_USER_ADD(u);
+
        h.ipc0 = h.ipc1 = 20;             /* phase for cosine */
        h.dcs = 0xF1;                                    /* default */
        if (!data) {
                ast_log (LOG_ERROR, "Requires queue name at least\n");
+               LOCAL_USER_REMOVE(u);
                return -1;
        }
 
@@ -1379,11 +1383,13 @@ static int sms_exec (struct ast_channel *chan, void *data)
                        answer = 0;
                if (!*d || *d == '|') {
                        ast_log (LOG_ERROR, "Requires queue name\n");
+                       LOCAL_USER_REMOVE(u);
                        return -1;
                }
                for (p = d; *p && *p != '|'; p++);
                if (p - d >= sizeof (h.queue)) {
                        ast_log (LOG_ERROR, "Queue name too long\n");
+                       LOCAL_USER_REMOVE(u);
                        return -1;
                }
                strncpy (h.queue, d, p - d);
@@ -1452,6 +1458,7 @@ static int sms_exec (struct ast_channel *chan, void *data)
                        h.rx = 0;                                 /* sent message */
                        h.mr = -1;
                        sms_writefile (&h);
+                       LOCAL_USER_REMOVE(u);
                        return 0;
                }
 
@@ -1463,7 +1470,6 @@ static int sms_exec (struct ast_channel *chan, void *data)
                }
        }
 
-       LOCAL_USER_ADD (u);
        if (chan->_state != AST_STATE_UP)
                ast_answer (chan);
 
@@ -1475,14 +1481,14 @@ static int sms_exec (struct ast_channel *chan, void *data)
        if (res >= 0)
                res = ast_set_read_format (chan, AST_FORMAT_SLINEAR);
        if (res < 0) {
-               LOCAL_USER_REMOVE (u);
                ast_log (LOG_ERROR, "Unable to set to linear mode, giving up\n");
+               LOCAL_USER_REMOVE (u);
                return -1;
        }
 
        if (ast_activate_generator (chan, &smsgen, &h) < 0) {
-               LOCAL_USER_REMOVE (u);
                ast_log (LOG_ERROR, "Failed to activate generator on '%s'\n", chan->name);
+               LOCAL_USER_REMOVE (u);
                return -1;
        }
 
index 9c57465eb1edcb35f6f77deeecf8db2e75642de3..96fa6c12be8bbd1d304e9bc004ea9b1b47a846f7 100755 (executable)
@@ -60,17 +60,18 @@ static int softhangup_exec(struct ast_channel *chan, void *data)
        char *options, *cut, *cdata, *match;
        char name[AST_CHANNEL_NAME] = "";
        int all = 0;
-
-       if (!data) {
+       
+       if (!data || ast_strlen_zero(data)) {
                 ast_log(LOG_WARNING, "SoftHangup requires an argument (Technology/resource)\n");
                return 0;
        }
        
+       LOCAL_USER_ADD(u);
+
        cdata = ast_strdupa(data);
        match = strsep(&cdata, "|");
        options = strsep(&cdata, "|");
        all = options && strchr(options,'a');
-       LOCAL_USER_ADD(u);
        c = ast_channel_walk_locked(NULL);
        while (c) {
                strncpy(name, c->name, sizeof(name)-1);
@@ -95,6 +96,7 @@ static int softhangup_exec(struct ast_channel *chan, void *data)
                }
                c = ast_channel_walk_locked(c);
        }
+       
        LOCAL_USER_REMOVE(u);
 
        return 0;
index 94dc8ea04008acaf6ce6b76f9e7882bb752356f1..810e00f722572f9dea986f2f93e91314c113b6e4 100755 (executable)
@@ -44,9 +44,6 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 
 #include "libpq-fe.h"
 
-#define EXTRA_LOG 0
-
-
 static char *tdesc = "Simple PostgreSQL Interface";
 
 static char *app = "PGSQL";
@@ -501,23 +498,19 @@ static int aPGSQL_debug(struct ast_channel *chan, void *data) {
        ast_log(LOG_WARNING,"Debug : %s\n",(char *)data);
        return(0);
 }
-               
-       
 
 static int PGSQL_exec(struct ast_channel *chan, void *data)
 {
        struct localuser *u;
        int result;
 
-#if EXTRA_LOG
-       printf("PRSQL_exec: data=%s\n",(char*)data);
-#endif
-
-       if (!data) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "APP_PGSQL requires an argument (see manual)\n");
                return -1;
        }
+       
        LOCAL_USER_ADD(u);
+
        result=0;
        
        if (strncasecmp("connect",data,strlen("connect"))==0) {
@@ -540,8 +533,8 @@ static int PGSQL_exec(struct ast_channel *chan, void *data)
        }
                
        LOCAL_USER_REMOVE(u);                                                                                
+       
        return result;
-
 }
 
 int unload_module(void)
index 8c1c97e8807f408a74606bdaf2c3eb138760c15c..f8837712714058c8d174bb6d0e183a8cff34dc8e 100755 (executable)
@@ -64,6 +64,9 @@ static int striplsd_exec(struct ast_channel *chan, void *data)
        int maxbytes = 0;
        int stripcount = 0;
        int extlen = strlen(chan->exten);
+       struct localuser *u;
+
+       LOCAL_USER_ADD(u);
 
        maxbytes = sizeof(newexten) - 1;
        if (data) {
@@ -71,6 +74,7 @@ static int striplsd_exec(struct ast_channel *chan, void *data)
        }
        if (!stripcount) {
                ast_log(LOG_DEBUG, "Ignoring, since number of digits to strip is 0\n");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
        if (extlen > stripcount) {
@@ -80,6 +84,9 @@ static int striplsd_exec(struct ast_channel *chan, void *data)
                strncpy(newexten, chan->exten, maxbytes);
        }
        strncpy(chan->exten, newexten, sizeof(chan->exten)-1);
+
+       LOCAL_USER_REMOVE(u);
+
        return 0;
 }
 
index bb1b835775cb6b3f6f95f5378b9a865df0d7b2a2..b06628cf04910d9d25eada4f78493b73a7b04088 100755 (executable)
@@ -75,6 +75,9 @@ static int substring_exec(struct ast_channel *chan, void *data)
   char newexten[AST_MAX_EXTENSION] = "";
   char *count1, *count2;
   char *first, *second, *stringp;
+  struct localuser *u;
+
+  LOCAL_USER_ADD(u);
 
   stringp=alloca(strlen(data)+1);
   ast_log(LOG_WARNING, "The use of Substring application is deprecated. Please use ${variable:a:b} instead\n");
@@ -87,6 +90,7 @@ static int substring_exec(struct ast_channel *chan, void *data)
     count2=strsep(&stringp,"\0");
     if (!first || !second || !count1 || !count2) {
       ast_log(LOG_DEBUG, "Ignoring, since there is no argument: variable or string or count1 or count2\n");
+      LOCAL_USER_REMOVE(u);
       return 0;
     }
     icount1=atoi(count1);
@@ -118,6 +122,9 @@ static int substring_exec(struct ast_channel *chan, void *data)
   } else {
     ast_log(LOG_DEBUG, "Ignoring, no parameters\n");
   }
+
+  LOCAL_USER_REMOVE(u);
+
   return 0;
 }
 
index 00fed1058acedb2df9543de39032b798501920b4..6aa71f1041f507e87bb31568674987e0947c8383 100755 (executable)
@@ -89,11 +89,13 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode
 {
        int res=0;
        struct localuser *u;
-       if (!data) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "System requires an argument(command)\n");
                pbx_builtin_setvar_helper(chan, chanvar, "FAILURE");
                return failmode;
        }
+
        LOCAL_USER_ADD(u);
 
        /* Do our thing here */
@@ -120,6 +122,7 @@ static int system_exec_helper(struct ast_channel *chan, void *data, int failmode
        } 
 
        LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index 7729f616e99dcde50aaf194279976d0a99b3fbf6..ec2012f51ccb795854ace1df9005cf5563b2f23b 100755 (executable)
@@ -65,7 +65,7 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
 {
        int res = 0;
        struct localuser *u;
-       char tmp[256];
+       char *tmp;
        char *options;
        char *stringp;
        struct ast_frame *fr;
@@ -77,11 +77,21 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
        int x;
        int origrformat=0;
        struct ast_dsp *dsp;
-       if (!data || ast_strlen_zero((char *)data)) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "BackgroundDetect requires an argument (filename)\n");
                return -1;
        }
-       ast_copy_string(tmp, (char *)data, sizeof(tmp));
+
+       LOCAL_USER_ADD(u);
+
+       tmp = ast_strdupa(data);
+       if (!tmp) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }       
+
        stringp=tmp;
        strsep(&stringp, "|");
        options = strsep(&stringp, "|");
@@ -101,7 +111,6 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
        }
        ast_log(LOG_DEBUG, "Preparing detect of '%s', sil=%d,min=%d,max=%d\n", 
                                                tmp, sil, min, max);
-       LOCAL_USER_ADD(u);
        if (chan->_state != AST_STATE_UP) {
                /* Otherwise answer unless we're supposed to send this while on-hook */
                res = ast_answer(chan);
index 4ded538d3f60e5fdc3a188797ea4c0982f137b0e..eb6a7efde3e16a1a01f393b3c5ca125f9347c942 100755 (executable)
@@ -43,6 +43,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/pbx.h"
 #include "asterisk/utils.h"
 
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
 static char *tdesc = "Interface Test Application";
 
 static char *tests_descrip = 
@@ -123,10 +127,6 @@ static int sendnoise(struct ast_channel *chan, int ms)
        return res;     
 }
 
-STANDARD_LOCAL_USER;
-
-LOCAL_USER_DECL;
-
 static int testclient_exec(struct ast_channel *chan, void *data)
 {
        struct localuser *u;
@@ -135,7 +135,6 @@ static int testclient_exec(struct ast_channel *chan, void *data)
        char fn[80];
        char serverver[80];
        FILE *f;
-       LOCAL_USER_ADD(u);
        
        /* Check for test id */
        if (!testid || ast_strlen_zero(testid)) {
@@ -143,6 +142,8 @@ static int testclient_exec(struct ast_channel *chan, void *data)
                return -1;
        }
        
+       LOCAL_USER_ADD(u);
+
        if (chan->_state != AST_STATE_UP)
                res = ast_answer(chan);
        
index 7a1d17b6ff38d8efeb0023d54a7669c1bcbc78c9..44e1b24d98dcb91bb31ee1cb3197e1c9a4f46066 100755 (executable)
@@ -38,6 +38,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/module.h"
 #include "asterisk/options.h"
 
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
 static const char *tdesc = "Transfer";
 
 static const char *app = "Transfer";
@@ -61,10 +65,6 @@ static const char *descrip =
 "successful and there exists a priority n + 101,\n"
 "then that priority will be taken next.\n" ;
 
-STANDARD_LOCAL_USER;
-
-LOCAL_USER_DECL;
-
 static int transfer_exec(struct ast_channel *chan, void *data)
 {
        int res;
@@ -81,12 +81,15 @@ static int transfer_exec(struct ast_channel *chan, void *data)
                return 0;
        }
 
+       LOCAL_USER_ADD(u);
+
        if ((slash = strchr(dest, '/')) && (len = (slash - dest))) {
                tech = dest;
                dest = slash + 1;
                /* Allow execution only if the Tech/destination agrees with the type of the channel */
                if (strncasecmp(chan->type, tech, len)) {
                        pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
+                       LOCAL_USER_REMOVE(u);
                        return 0;
                }
        }
@@ -94,11 +97,10 @@ static int transfer_exec(struct ast_channel *chan, void *data)
        /* Check if the channel supports transfer before we try it */
        if (!chan->tech->transfer) {
                pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "UNSUPPORTED");
+               LOCAL_USER_REMOVE(u);
                return 0;
        }
 
-       LOCAL_USER_ADD(u);
-
        res = ast_transfer(chan, dest);
 
        if (res < 0) {
index f1970adf62fc664763fe2e3bd33a709293eef971..4ea18e62bbbd44502700ae93e07da8042cf2ed11 100755 (executable)
@@ -40,6 +40,10 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
 #include "asterisk/enum.h"
 #include "asterisk/utils.h"
 
+STANDARD_LOCAL_USER;
+
+LOCAL_USER_DECL;
+
 static char *tdesc = "TXTCIDName";
 
 static char *app = "TXTCIDName";
@@ -51,10 +55,6 @@ static char *descrip =
 "the variable 'TXTCIDNAME'. TXTCIDName will either be blank\n"
 "or return the value found in the TXT record in DNS.\n" ;
 
-STANDARD_LOCAL_USER;
-
-LOCAL_USER_DECL;
-
 static int txtcidname_exec(struct ast_channel *chan, void *data)
 {
        int res=0;
@@ -64,6 +64,8 @@ static int txtcidname_exec(struct ast_channel *chan, void *data)
        struct localuser *u;
        static int dep_warning = 0;
 
+       LOCAL_USER_ADD(u);
+       
        if (!dep_warning) {
                ast_log(LOG_WARNING, "The TXTCIDName application has been deprecated in favor of the TXTCIDNAME dialplan function.\n");
                dep_warning = 1;
@@ -73,11 +75,11 @@ static int txtcidname_exec(struct ast_channel *chan, void *data)
                ast_log(LOG_WARNING, "TXTCIDName requires an argument (extension)\n");
                res = 1;
        }
-       LOCAL_USER_ADD(u);
+       
        if (!res) {
                res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt));
        }
-       LOCAL_USER_REMOVE(u);
+       
        /* Parse it out */
        if (res > 0) {
                if (!ast_strlen_zero(txt)) {
@@ -91,6 +93,9 @@ static int txtcidname_exec(struct ast_channel *chan, void *data)
                ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101);
        } else if (res > 0)
                res = 0;
+
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
index 512ea9d9ee3180277008b1187cc55a33d6a5daca..9f8a2badf8d61e19172e88bfe2f3b897d497c653 100755 (executable)
@@ -74,20 +74,29 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
 {
        int res = 0;
        struct localuser *u;
-       char tmp[256];
+       char *tmp;
        char *options;
        int local_option_wait=0;
        int local_option_jump = 0;
        struct ast_frame *f;
        char *stringp=NULL;
        char *status = "FAILURE";
-
-       if (!data || !strlen((char *)data)) {
+       
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "SendURL requires an argument (URL)\n");
                pbx_builtin_setvar_helper(chan, "SENDURLSTATUS", status);
                return -1;
        }
-       strncpy(tmp, (char *)data, sizeof(tmp)-1);
+
+       LOCAL_USER_ADD(u);
+
+       tmp = ast_strdupa(data);
+       if (!tmp) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+
        stringp=tmp;
        strsep(&stringp, "|");
        options = strsep(&stringp, "|");
@@ -95,7 +104,7 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
                local_option_wait = 1;
        if (options && !strcasecmp(options, "j"))
                local_option_jump = 1;
-       LOCAL_USER_ADD(u);
+       
        if (!ast_channel_supports_html(chan)) {
                /* Does not support transport */
                if (local_option_jump || option_priority_jumping)
index 681231ab01bc1a03b5a64f5ef2ede6ec23adad13..4facd489d26e04be5c202852617a7815acb132d8 100755 (executable)
@@ -62,24 +62,31 @@ LOCAL_USER_DECL;
 static int userevent_exec(struct ast_channel *chan, void *data)
 {
        struct localuser *u;
-       char info[512];
-    char eventname[512];
+       char *info;
+       char eventname[512];
        char *eventbody;
 
-       if (!data || !strlen(data)) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_WARNING, "UserEvent requires an argument (eventname|optional event body)\n");
                return -1;
        }
 
-       strncpy(info, (char *)data, strlen((char *)data) + AST_MAX_EXTENSION-1);
+       LOCAL_USER_ADD(u);
+
+       info = ast_strdupa(data);
+       if (!info) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+
        snprintf(eventname, sizeof(eventname), "UserEvent%s", info);
        eventbody = strchr(eventname, '|');
        if (eventbody) {
                *eventbody = '\0';
                eventbody++;
        }
-       LOCAL_USER_ADD(u);
-
+       
        if(eventbody) {
             ast_log(LOG_DEBUG, "Sending user event: %s, %s\n", eventname, eventbody);
             manager_event(EVENT_FLAG_USER, eventname, 
index e23bf1a06288c23b3da95f16d879fbbbf4c2c4de..3ff50bedcddd94fa2ea5bd89f42ac550f4384df4 100755 (executable)
@@ -56,6 +56,9 @@ static int verbose_exec(struct ast_channel *chan, void *data)
 {
        char *vtext;
        int vsize;
+       struct localuser *u;
+
+       LOCAL_USER_ADD(u);
 
        if (data) {
                vtext = ast_strdupa((char *)data);
@@ -93,6 +96,8 @@ static int verbose_exec(struct ast_channel *chan, void *data)
                }
        }
 
+       LOCAL_USER_REMOVE(u);
+
        return 0;
 }
 
index 54351f9d6043d1beb13ec1d955f0b4d03b38013c..7cd529ad324c27a50a29b5c2f77031fd8c2a6afd 100755 (executable)
@@ -5478,9 +5478,9 @@ static int vm_exec(struct ast_channel *chan, void *data)
        struct ast_flags flags = { 0 };
        char *opts[OPT_ARG_ARRAY_SIZE];
        
-       memset(&leave_options, 0, sizeof(leave_options));
-
        LOCAL_USER_ADD(u);
+       
+       memset(&leave_options, 0, sizeof(leave_options));
 
        if (chan->_state != AST_STATE_UP)
                ast_answer(chan);
@@ -5523,16 +5523,18 @@ static int vm_exec(struct ast_channel *chan, void *data)
                }
        } else {
                res = ast_app_getdata(chan, "vm-whichbox", tmp, sizeof(tmp) - 1, 0);
-               if (res < 0)
+               if (res < 0) {
+                       LOCAL_USER_REMOVE(u);
                        return res;
-               if (ast_strlen_zero(tmp))
+               }
+               if (ast_strlen_zero(tmp)) {
+                       LOCAL_USER_REMOVE(u);
                        return 0;
+               }       
        }
 
        res = leave_voicemail(chan, argv[0], &leave_options);
 
-       LOCAL_USER_REMOVE(u);
-       
        if (res == ERROR_LOCK_PATH) {
                ast_log(LOG_ERROR, "Could not leave voicemail. The path is already locked.\n");
                /*Send the call to n+101 priority, where n is the current priority*/
@@ -5541,6 +5543,8 @@ static int vm_exec(struct ast_channel *chan, void *data)
                res = 0;
        }
        
+       LOCAL_USER_REMOVE(u);
+
        return res;
 }
 
@@ -5589,13 +5593,20 @@ static int vm_box_exists(struct ast_channel *chan, void *data)
        struct ast_vm_user svm;
        char *context, *box;
 
-       if (!data || !(box = ast_strdupa(data))) {
+       if (!data || ast_strlen_zero(data)) {
                ast_log(LOG_ERROR, "MailboxExists requires an argument: (vmbox[@context])\n");
                return -1;
        }
 
        LOCAL_USER_ADD(u);
 
+       box = ast_strdupa(data);
+       if (!box) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+
        if ((context = strchr(box, '@'))) {
                *context = '\0';
                context++;
@@ -5618,6 +5629,8 @@ static int vmauthenticate(struct ast_channel *chan, void *data)
        int silent = 0;
        int res = -1;
 
+       LOCAL_USER_ADD(u);
+       
        if (s) {
                s = ast_strdupa(s);
                if (!s) {
@@ -5637,8 +5650,6 @@ static int vmauthenticate(struct ast_channel *chan, void *data)
                silent = (strchr(options, 's')) != NULL;
        }
 
-       LOCAL_USER_ADD(u);
-
        if (!vm_authenticate(chan, mailbox, sizeof(mailbox), &vmus, context, NULL, 0, 3, silent)) {
                pbx_builtin_setvar_helper(chan, "AUTH_MAILBOX", mailbox);
                pbx_builtin_setvar_helper(chan, "AUTH_CONTEXT", vmus.context);
index 30ba1d45d27581b6b53fa005c967e57c58abdee1..7c80e9463cf2ea62263a64fd5de71346d09ff28a 100755 (executable)
@@ -61,12 +61,15 @@ static int waitforring_exec(struct ast_channel *chan, void *data)
        struct ast_frame *f;
        int res = 0;
        int ms;
+
        if (!data || (sscanf(data, "%d", &ms) != 1)) {
                 ast_log(LOG_WARNING, "WaitForRing requires an argument (minimum seconds)\n");
                return 0;
        }
-       ms *= 1000;
+
        LOCAL_USER_ADD(u);
+
+       ms *= 1000;
        while(ms > 0) {
                ms = ast_waitfor(chan, ms);
                if (ms < 0) {
index a5e7a7766e5a34db95f85f4990f192ba9b7119bc..5521e202ac099d680b9c3f6d817b71ab8433d4af 100755 (executable)
@@ -152,6 +152,8 @@ static int waitforsilence_exec(struct ast_channel *chan, void *data)
        int maxsilence = 1000;
        int iterations = 1, i;
 
+       LOCAL_USER_ADD(u);
+       
        res = ast_answer(chan); /* Answer the channel */
 
        if (!data || ((sscanf(data, "%d|%d", &maxsilence, &iterations) != 2) &&
@@ -161,7 +163,7 @@ static int waitforsilence_exec(struct ast_channel *chan, void *data)
 
        if (option_verbose > 2)
                ast_verbose(VERBOSE_PREFIX_3 "Waiting %d time(s) for %d ms silence\n", iterations, maxsilence);
-       LOCAL_USER_ADD(u);
+       
        res = 1;
        for (i=0; (i<iterations) && (res == 1); i++) {
                res = do_waiting(chan, maxsilence);
index 49c631221c69853b8de9dc5d1a252b35ae4df833..4f6a54144b7c3635009ee67a516c0316c441b141 100755 (executable)
@@ -84,7 +84,14 @@ static int execif_exec(struct ast_channel *chan, void *data) {
        struct ast_app *app = NULL;
 
        LOCAL_USER_ADD(u);
-       expr = ast_strdupa((char *) data);
+
+       expr = ast_strdupa(data);
+       if (!expr) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+
        if ((myapp = strchr(expr,'|'))) {
                *myapp = '\0';
                myapp++;
index a5b372446cd26217cbb5d477b2286fcad28fdc27..41e3de3648c4c2a7604cc9a6a30e0b2e26705434 100755 (executable)
@@ -68,7 +68,7 @@ static int zapateller_exec(struct ast_channel *chan, void *data)
 
        stringp=data;
         c = strsep(&stringp, "|");
-        while(c && strlen(c)) {
+        while(c && !ast_strlen_zero(c)) {
                if (!strcasecmp(c, "answer"))
                        answer = 1;
                else if (!strcasecmp(c, "nocallerid"))
index 148543381adb501f74216f5d276ad17ee23ed616..3f3a8ae66818517791ca4d1f84a5e27e1e554cb6 100755 (executable)
@@ -267,14 +267,17 @@ static int conf_exec(struct ast_channel *chan, void *data)
        int confno = 0;
        char confstr[80] = "";
 
+       LOCAL_USER_ADD(u);
+       
        if (data && !ast_strlen_zero(data)) {
                if ((sscanf(data, "Zap/%d", &confno) != 1) &&
                    (sscanf(data, "%d", &confno) != 1)) {
                        ast_log(LOG_WARNING, "ZapBarge Argument (if specified) must be a channel number, not '%s'\n", (char *)data);
+                       LOCAL_USER_REMOVE(u);
                        return 0;
                }
        }
-       LOCAL_USER_ADD(u);
+       
        if (chan->_state != AST_STATE_UP)
                ast_answer(chan);
 
index 76a81bd707e1d327c95a12629ba17df75fa3ea25..6e2ea3aef046e97cea90caf2281ebc74d84d106c 100755 (executable)
@@ -197,14 +197,22 @@ static void run_ras(struct ast_channel *chan, char *args)
 static int zapras_exec(struct ast_channel *chan, void *data)
 {
        int res=-1;
-       char args[256];
+       char *args;
        struct localuser *u;
        ZT_PARAMS ztp;
 
        if (!data) 
                data = "";
+
        LOCAL_USER_ADD(u);
-       ast_copy_string(args, data, sizeof(args));
+
+       args = ast_strdupa(data);
+       if (!args) {
+               ast_log(LOG_ERROR, "Out of memory\n");
+               LOCAL_USER_REMOVE(u);
+               return -1;
+       }
+       
        /* Answer the channel if it's not up */
        if (chan->_state != AST_STATE_UP)
                ast_answer(chan);