Massive cleanups to applications for LOCAL_USER handling and some other things.

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
1.2-netsec
Russell Bryant 21 years ago
parent e5afdbbe16
commit 4aa7912057

@ -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;
}

@ -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;
}

@ -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) {

@ -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;
}

@ -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, "|");

@ -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) {

@ -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;
}

@ -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);

@ -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");

@ -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;
}

@ -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++;

@ -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;) {

@ -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;

@ -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))

@ -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))

@ -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;
}

@ -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;
}

@ -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);

@ -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;
}

@ -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;
}

@ -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)) {

@ -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;
}

@ -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;
}

@ -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);

@ -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;
}

@ -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;
}

@ -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;
}

@ -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, "|");

@ -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);

@ -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;
}

@ -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));

@ -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);

@ -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;
}

@ -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);

@ -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;
}

@ -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;

@ -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)

@ -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;
}

@ -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 */

@ -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);

@ -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))

@ -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 */

@ -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))

@ -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);

@ -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;
}

@ -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;
}

@ -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);

@ -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;
}

@ -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);
}

@ -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)

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;
}

@ -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;

@ -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)

@ -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;
}

@ -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;
}

@ -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;
}

@ -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);

@ -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);

@ -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) {

@ -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;
}

@ -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)

@ -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,

@ -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;
}

@ -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);

@ -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) {

@ -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);

@ -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++;

@ -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"))

@ -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);

@ -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);

Loading…
Cancel
Save