revert my pass through the tree to remove checks of the result of ast_strdupa

(revisions 8378 through 8381)


git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@8387 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2006-01-21 17:50:04 +00:00
parent fbdc8ce317
commit 9fa6eb5e07
51 changed files with 544 additions and 156 deletions

View File

@ -129,6 +129,11 @@ static int auth_exec(struct ast_channel *chan, void *data)
}
argcopy = ast_strdupa(data);
if (!argcopy) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(arglist,argcopy);

View File

@ -383,7 +383,10 @@ static int chanspy_exec(struct ast_channel *chan, void *data)
struct ast_flags flags;
signed char zero_volume = 0;
args = ast_strdupa(data);
if (!(args = ast_strdupa((char *)data))) {
ast_log(LOG_ERROR, "Out of memory!\n");
return -1;
}
LOCAL_USER_ADD(u);

View File

@ -129,6 +129,11 @@ static char *acf_curl_exec(struct ast_channel *chan, char *cmd, char *data, char
LOCAL_USER_ACF_ADD(u);
info = ast_strdupa(data);
if (!info) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return buf;
}
AST_STANDARD_APP_ARGS(args, info);

View File

@ -76,6 +76,11 @@ static int deltree_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
argv = ast_strdupa(data);
if (!argv) {
ast_log(LOG_ERROR, "Memory allocation failed\n");
LOCAL_USER_REMOVE(u);
return 0;
}
if (strchr(argv, '/')) {
family = strsep(&argv, "/");
@ -117,6 +122,11 @@ static int del_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
argv = ast_strdupa(data);
if (!argv) {
ast_log (LOG_ERROR, "Memory allocation failed\n");
LOCAL_USER_REMOVE(u);
return 0;
}
if (strchr(argv, '/')) {
family = strsep(&argv, "/");

View File

@ -786,7 +786,11 @@ static int dial_exec_full(struct ast_channel *chan, void *data, struct ast_flags
LOCAL_USER_ADD(u);
parse = ast_strdupa(data);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory allocation failure\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
@ -1624,6 +1628,11 @@ static int retrydial_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
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));

View File

@ -111,6 +111,10 @@ static int dictate_exec(struct ast_channel *chan, void *data)
snprintf(dftbase, sizeof(dftbase), "%s/dictate", ast_config_AST_SPOOL_DIR);
if (!ast_strlen_zero(data)) {
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
} else
args.argc = 0;

View File

@ -433,6 +433,12 @@ static int directory_exec(struct ast_channel *chan, void *data)
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
if (args.options) {

View File

@ -162,6 +162,11 @@ static int disa_exec(struct ast_channel *chan, void *data)
ast_log(LOG_DEBUG, "Responsetimeout: %d\n", firstdigittimeout);
tmp = ast_strdupa(data);
if (!tmp) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, tmp);

View File

@ -73,22 +73,27 @@ static int exec_exec(struct ast_channel *chan, void *data)
/* Check and parse arguments */
if (data) {
s = ast_strdupa(data);
appname = strsep(&s, "(");
s = ast_strdupa((char *)data);
if (s) {
endargs = strrchr(s, ')');
if (endargs)
*endargs = '\0';
pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
}
if (appname) {
app = pbx_findapp(appname);
if (app) {
res = pbx_exec(chan, app, args, 1);
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
res = -1;
appname = strsep(&s, "(");
if (s) {
endargs = strrchr(s, ')');
if (endargs)
*endargs = '\0';
pbx_substitute_variables_helper(chan, s, args, MAXRESULT - 1);
}
if (appname) {
app = pbx_findapp(appname);
if (app) {
res = pbx_exec(chan, app, args, 1);
} else {
ast_log(LOG_WARNING, "Could not find application (%s)\n", appname);
res = -1;
}
}
} else {
ast_log(LOG_ERROR, "Out of memory\n");
res = -1;
}
}

View File

@ -272,6 +272,11 @@ static int app_exec(struct ast_channel *chan, void *data)
}
buf = ast_strdupa(data);
if (!buf) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
argc = ast_app_separate_args(buf, '|', argv, sizeof(argv) / sizeof(argv[0]));

View File

@ -340,6 +340,12 @@ static int festival_exec(struct ast_channel *chan, void *vdata)
}
data = ast_strdupa(vdata);
if (!data) {
ast_log(LOG_ERROR, "Out of memery\n");
ast_config_destroy(cfg);
LOCAL_USER_REMOVE(u);
return -1;
}
intstr = strchr(data, '|');
if (intstr) {

View File

@ -130,6 +130,11 @@ static int hasvoicemail_exec(struct ast_channel *chan, void *data)
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;
}
AST_STANDARD_APP_ARGS(args, input);
@ -189,6 +194,11 @@ static char *acf_vmcount_exec(struct ast_channel *chan, char *cmd, char *data, c
buf[0] = '\0';
argsstr = ast_strdupa(data);
if (!argsstr) {
ast_log(LOG_ERROR, "Out of memory");
LOCAL_USER_REMOVE(u);
return buf;
}
AST_STANDARD_APP_ARGS(args, argsstr);

View File

@ -78,7 +78,11 @@ static int sendimage_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
parse = ast_strdupa(data);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -308,6 +308,11 @@ static int macroif_exec(struct ast_channel *chan, void *data)
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';

View File

@ -1779,6 +1779,10 @@ static struct ast_conference *find_conf(struct ast_channel *chan, char *confno,
continue;
parse = ast_strdupa(var->value);
if (!parse) {
ast_log(LOG_ERROR, "Out of Memory!\n");
return NULL;
}
AST_STANDARD_APP_ARGS(args, parse);
if (!strcasecmp(args.confno, confno)) {
@ -1835,6 +1839,11 @@ static int count_exec(struct ast_channel *chan, void *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;
}
AST_STANDARD_APP_ARGS(args, localdata);

View File

@ -333,7 +333,11 @@ static int mixmonitor_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
parse = ast_strdupa(data);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -139,6 +139,11 @@ static int osplookup_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
temp = ast_strdupa(data);
if (!temp) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, temp);
@ -197,6 +202,11 @@ static int ospnext_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
temp = ast_strdupa(data);
if (!temp) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, temp);
@ -266,6 +276,11 @@ static int ospfinished_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
temp = ast_strdupa(data);
if (!temp) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, temp);

View File

@ -164,6 +164,11 @@ static int page_exec(struct ast_channel *chan, void *data)
};
options = ast_strdupa(data);
if (!options) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return -1;
}
tmp = strsep(&options, "|");
if (options)

View File

@ -90,6 +90,10 @@ static int playback_exec(struct ast_channel *chan, void *data)
}
tmp = ast_strdupa(data);
if (!tmp) {
ast_log(LOG_ERROR, "Out of memory!\n");
return -1;
}
LOCAL_USER_ADD(u);
AST_STANDARD_APP_ARGS(args, tmp);

View File

@ -118,6 +118,11 @@ static int privacy_exec (struct ast_channel *chan, void *data)
if (!ast_strlen_zero((char *)data))
{
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -2645,7 +2645,11 @@ static int pqm_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
parse = ast_strdupa(data);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
@ -2697,7 +2701,11 @@ static int upqm_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
parse = ast_strdupa(data);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
@ -2751,7 +2759,11 @@ static int rqm_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
parse = ast_strdupa(data);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
@ -2815,11 +2827,7 @@ static int aqm_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -74,6 +74,11 @@ static int random_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
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))

View File

@ -118,6 +118,11 @@ static int read_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
argcopy = ast_strdupa(data);
if (!argcopy) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(arglist, argcopy);

View File

@ -74,6 +74,11 @@ static int readfile_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
s = ast_strdupa(data);
if (!s) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return -1;
}
varname = strsep(&s, "=");
file = strsep(&s, "|");

View File

@ -148,19 +148,20 @@ static int realtime_update_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
family = ast_strdupa(data);
if ((colmatch = strchr(family,'|'))) {
crop_data(colmatch);
if ((value = strchr(colmatch,'|'))) {
crop_data(value);
if ((newcol = strchr(value,'|'))) {
crop_data(newcol);
if ((newval = strchr(newcol,'|')))
crop_data(newval);
if ((family = ast_strdupa(data))) {
if ((colmatch = strchr(family,'|'))) {
crop_data(colmatch);
if ((value = strchr(colmatch,'|'))) {
crop_data(value);
if ((newcol = strchr(value,'|'))) {
crop_data(newcol);
if ((newval = strchr(newcol,'|')))
crop_data(newval);
}
}
}
}
if (!newval) {
if (! (family && value && colmatch && newcol && newval) ) {
ast_log(LOG_ERROR,"Invalid input: usage %s\n",UUSAGE);
res = -1;
} else {
@ -192,16 +193,17 @@ static int realtime_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
family = ast_strdupa(data);
if ((colmatch = strchr(family,'|'))) {
crop_data(colmatch);
if ((value = strchr(colmatch,'|'))) {
crop_data(value);
if ((prefix = strchr(value,'|')))
crop_data(prefix);
if ((family = ast_strdupa(data))) {
if ((colmatch = strchr(family,'|'))) {
crop_data(colmatch);
if ((value = strchr(colmatch,'|'))) {
crop_data(value);
if ((prefix = strchr(value,'|')))
crop_data(prefix);
}
}
}
if (!value) {
if (! (family && value && colmatch) ) {
ast_log(LOG_ERROR,"Invalid input: usage %s\n",USAGE);
res = -1;
} else {

View File

@ -117,6 +117,11 @@ static int record_exec(struct ast_channel *chan, void *data)
/* 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, "|");

View File

@ -92,21 +92,26 @@ static int sayunixtime_exec(struct ast_channel *chan, void *data)
}
if (data) {
s = ast_strdupa(data);
timec = strsep(&s,"|");
if ((timec) && (*timec != '\0')) {
long timein;
if (sscanf(timec,"%ld",&timein) == 1) {
unixtime = (time_t)timein;
}
}
s = data;
s = ast_strdupa(s);
if (s) {
zone = strsep(&s,"|");
if (zone && (*zone == '\0'))
zone = NULL;
if (s) {
format = s;
timec = strsep(&s,"|");
if ((timec) && (*timec != '\0')) {
long timein;
if (sscanf(timec,"%ld",&timein) == 1) {
unixtime = (time_t)timein;
}
}
if (s) {
zone = strsep(&s,"|");
if (zone && (*zone == '\0'))
zone = NULL;
if (s) {
format = s;
}
}
} else {
ast_log(LOG_ERROR, "Out of memory error\n");
}
}

View File

@ -75,6 +75,11 @@ static int senddtmf_exec(struct ast_channel *chan, void *data)
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';

View File

@ -87,8 +87,14 @@ static int sendtext_exec(struct ast_channel *chan, void *data)
ast_log(LOG_WARNING, "SendText requires an argument (text[|options])\n");
LOCAL_USER_REMOVE(u);
return -1;
} else
} else {
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -118,6 +118,11 @@ static int setcallerid_exec(struct ast_channel *chan, void *data)
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) {

View File

@ -88,6 +88,11 @@ static int app_exec(struct ast_channel *chan, void *data)
/* 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_app_separate_args(args, '|', argv, sizeof(argv) / sizeof(argv[0])))) {
dummy = argv[0];

View File

@ -130,6 +130,10 @@ static int gosubif_exec(struct ast_channel *chan, void *data)
}
args = ast_strdupa((char *)data);
if (!args) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
LOCAL_USER_ADD(u);

View File

@ -89,6 +89,11 @@ static int background_detect_exec(struct ast_channel *chan, void *data)
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, "|");

View File

@ -88,14 +88,19 @@ static int transfer_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
if (ast_strlen_zero(data)) {
if (ast_strlen_zero((char *)data)) {
ast_log(LOG_WARNING, "Transfer requires an argument ([Tech/]destination[|options])\n");
LOCAL_USER_REMOVE(u);
pbx_builtin_setvar_helper(chan, "TRANSFERSTATUS", "FAILURE");
return 0;
} else {
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
}
parse = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -94,8 +94,14 @@ static int sendurl_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
stringp = tmp = ast_strdupa(data);
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, "|");
if (options && !strcasecmp(options, "wait"))

View File

@ -75,6 +75,11 @@ static int userevent_exec(struct ast_channel *chan, void *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;
}
snprintf(eventname, sizeof(eventname), "UserEvent%s", info);
eventbody = strchr(eventname, '|');

View File

@ -67,34 +67,38 @@ static int verbose_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
if (data) {
vtext = ast_strdupa(data);
char *tmp = strsep(&vtext, "|,");
vtext = ast_strdupa((char *)data);
if (vtext) {
if (sscanf(tmp, "%d", &vsize) != 1) {
char *tmp = strsep(&vtext, "|,");
if (vtext) {
if (sscanf(tmp, "%d", &vsize) != 1) {
vsize = 0;
ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext);
}
} else {
vtext = tmp;
vsize = 0;
ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext);
}
if (option_verbose >= vsize) {
switch (vsize) {
case 0:
ast_verbose("%s\n", vtext);
break;
case 1:
ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext);
break;
case 2:
ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext);
break;
case 3:
ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext);
break;
default:
ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext);
}
}
} else {
vtext = tmp;
vsize = 0;
}
if (option_verbose >= vsize) {
switch (vsize) {
case 0:
ast_verbose("%s\n", vtext);
break;
case 1:
ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext);
break;
case 2:
ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext);
break;
case 3:
ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext);
break;
default:
ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext);
}
ast_log(LOG_ERROR, "Out of memory\n");
}
}
@ -117,6 +121,11 @@ static int log_exec(struct ast_channel *chan, void *data)
}
ltext = ast_strdupa(data);
if (!ltext) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return 0;
}
level = strsep(&ltext, "|");

View File

@ -3284,23 +3284,28 @@ static int notify_new_message(struct ast_channel *chan, struct ast_vm_user *vmu,
snprintf(ext_context, sizeof(ext_context), "%s@%s", vmu->mailbox, vmu->context);
/* Attach only the first format */
stringp = fmt = ast_strdupa(fmt);
strsep(&stringp, "|");
fmt = ast_strdupa(fmt);
if (fmt) {
stringp = fmt;
strsep(&stringp, "|");
if (!ast_strlen_zero(vmu->email)) {
int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
char *myserveremail = serveremail;
attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
if (!ast_strlen_zero(vmu->serveremail))
myserveremail = vmu->serveremail;
sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category);
}
if (!ast_strlen_zero(vmu->email)) {
int attach_user_voicemail = ast_test_flag((&globalflags), VM_ATTACH);
char *myserveremail = serveremail;
attach_user_voicemail = ast_test_flag(vmu, VM_ATTACH);
if (!ast_strlen_zero(vmu->serveremail))
myserveremail = vmu->serveremail;
sendmail(myserveremail, vmu, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, fn, fmt, duration, attach_user_voicemail, category);
}
if (!ast_strlen_zero(vmu->pager)) {
char *myserveremail = serveremail;
if (!ast_strlen_zero(vmu->serveremail))
myserveremail = vmu->serveremail;
sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu, category);
if (!ast_strlen_zero(vmu->pager)) {
char *myserveremail = serveremail;
if (!ast_strlen_zero(vmu->serveremail))
myserveremail = vmu->serveremail;
sendpage(myserveremail, vmu->pager, msgnum, vmu->context, vmu->mailbox, cidnum, cidname, duration, vmu, category);
}
} else {
ast_log(LOG_ERROR, "Out of memory\n");
}
if (ast_test_flag(vmu, VM_DELETE)) {
@ -5053,6 +5058,11 @@ static int vm_execmain(struct ast_channel *chan, void *data)
);
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
@ -5638,6 +5648,11 @@ static int vm_box_exists(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
box = ast_strdupa(data);
if (!box) {
ast_log(LOG_ERROR, "Out of memory\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, box);
@ -5675,6 +5690,10 @@ static int vmauthenticate(struct ast_channel *chan, void *data)
if (s) {
s = ast_strdupa(s);
if (!s) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
user = strsep(&s, "|");
options = strsep(&s, "|");
if (user) {
@ -6121,22 +6140,28 @@ static int load_config(void)
if ((z = ast_malloc(sizeof(*z)))) {
char *msg_format, *timezone;
msg_format = ast_strdupa(var->value);
timezone = strsep(&msg_format, "|");
if (msg_format) {
ast_copy_string(z->name, var->name, sizeof(z->name));
ast_copy_string(z->timezone, timezone, sizeof(z->timezone));
ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
z->next = NULL;
if (zones) {
zonesl->next = z;
zonesl = z;
if (msg_format != NULL) {
timezone = strsep(&msg_format, "|");
if (msg_format) {
ast_copy_string(z->name, var->name, sizeof(z->name));
ast_copy_string(z->timezone, timezone, sizeof(z->timezone));
ast_copy_string(z->msg_format, msg_format, sizeof(z->msg_format));
z->next = NULL;
if (zones) {
zonesl->next = z;
zonesl = z;
} else {
zones = z;
zonesl = z;
}
} else {
zones = z;
zonesl = z;
ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
free(z);
}
} else {
ast_log(LOG_WARNING, "Invalid timezone definition at line %d\n", var->lineno);
ast_log(LOG_WARNING, "Out of memory while reading voicemail config\n");
free(z);
return -1;
}
} else {
return -1;

View File

@ -90,6 +90,11 @@ static int execif_exec(struct ast_channel *chan, void *data) {
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 ((myapp = strchr(expr,'|'))) {
*myapp = '\0';
@ -239,8 +244,9 @@ static int _while_exec(struct ast_channel *chan, void *data, int end)
snprintf(used_index, VAR_SIZE, "%d", used_index_i);
snprintf(new_index, VAR_SIZE, "%d", used_index_i + 1);
if (!end)
condition = ast_strdupa(data);
if (!end) {
condition = ast_strdupa((char *) data);
}
size = strlen(chan->context) + strlen(chan->exten) + 32;
my_name = alloca(size);

View File

@ -210,6 +210,11 @@ static int zapras_exec(struct ast_channel *chan, void *data)
LOCAL_USER_ADD(u);
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)

View File

@ -329,6 +329,10 @@ static struct agent_pvt *add_agent(char *agent, int pending)
struct agent_pvt *p, *prev;
parse = ast_strdupa(agent);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
return NULL;
}
/* Extract username (agt), password and name from agent (args). */
AST_NONSTANDARD_APP_ARGS(args, parse, ',');
@ -1763,7 +1767,11 @@ static int __login_exec(struct ast_channel *chan, void *data, int callbackmode)
LOCAL_USER_ADD(u);
parse = ast_strdupa(data);
if (!(parse = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory!\n");
LOCAL_USER_REMOVE(u);
return -1;
}
AST_STANDARD_APP_ARGS(args, parse);
@ -2503,6 +2511,10 @@ static char *function_agent(struct ast_channel *chan, char *cmd, char *data, cha
}
item = ast_strdupa(data);
if (!item) {
ast_log(LOG_ERROR, "Out of memory!\n");
return buf;
}
agentid = strsep(&item, ":");
if (!item)

View File

@ -2784,10 +2784,12 @@ static int create_addr(const char *peername, struct sockaddr_in *sin, struct cre
char *key = NULL;
family = ast_strdupa(peer->dbsecret);
key = strchr(family, '/');
if (key)
*key++ = '\0';
if (!key || ast_db_get(family, key, cai->secret, sizeof(cai->secret))) {
if (family) {
key = strchr(family, '/');
if (key)
*key++ = '\0';
}
if (!family || !key || ast_db_get(family, key, cai->secret, sizeof(cai->secret))) {
ast_log(LOG_WARNING, "Unable to retrieve database password for family/key '%s'!\n", peer->dbsecret);
if (ast_test_flag(peer, IAX_TEMPONLY))
destroy_peer(peer);
@ -3904,8 +3906,9 @@ static int decrypt_frame(int callno, struct ast_iax2_full_hdr *fh, struct ast_fr
unsigned char digest[16];
char *tmppw, *stringp;
stringp = ast_strdupa(iaxs[callno]->secret);
while ((tmppw = strsep(&stringp, ";"))) {
tmppw = ast_strdupa(iaxs[callno]->secret);
stringp = tmppw;
while((tmppw = strsep(&stringp, ";"))) {
MD5Init(&md5);
MD5Update(&md5, (unsigned char *)iaxs[callno]->challenge, strlen(iaxs[callno]->challenge));
MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
@ -4852,10 +4855,14 @@ static int check_access(int callno, struct sockaddr_in *sin, struct iax_ies *ies
if (!ast_strlen_zero(user->dbsecret)) {
char *family, *key=NULL;
family = ast_strdupa(user->dbsecret);
key = strchr(family, '/');
if (key)
*key++ = '\0';
if (!key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret))) {
if (family) {
key = strchr(family, '/');
if (key) {
*key = '\0';
key++;
}
}
if (!family || !key || ast_db_get(family, key, iaxs[callno]->secret, sizeof(iaxs[callno]->secret))) {
ast_log(LOG_WARNING, "Unable to retrieve database password for family/key '%s'!\n", user->dbsecret);
if (ast_test_flag(user, IAX_TEMPONLY)) {
destroy_user(user);
@ -4961,8 +4968,9 @@ static int authenticate_verify(struct chan_iax2_pvt *p, struct iax_ies *ies)
unsigned char digest[16];
char *tmppw, *stringp;
stringp = ast_strdupa(p->secret);
while ((tmppw = strsep(&stringp, ";"))) {
tmppw = ast_strdupa(p->secret);
stringp = tmppw;
while((tmppw = strsep(&stringp, ";"))) {
MD5Init(&md5);
MD5Update(&md5, (unsigned char *)p->challenge, strlen(p->challenge));
MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
@ -5090,8 +5098,9 @@ static int register_verify(int callno, struct sockaddr_in *sin, struct iax_ies *
unsigned char digest[16];
char *tmppw, *stringp;
stringp = ast_strdupa(p->secret);
while ((tmppw = strsep(&stringp, ";"))) {
tmppw = ast_strdupa(p->secret);
stringp = tmppw;
while((tmppw = strsep(&stringp, ";"))) {
MD5Init(&md5);
MD5Update(&md5, (unsigned char *)iaxs[callno]->challenge, strlen(iaxs[callno]->challenge));
MD5Update(&md5, (unsigned char *)tmppw, strlen(tmppw));
@ -8025,6 +8034,10 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
char *portstr;
tmp = ast_strdupa(srcaddr);
if (!tmp) {
ast_log(LOG_WARNING, "Out of memory!\n");
return -1;
}
addr = strsep(&tmp, ":");
portstr = tmp;
@ -8322,7 +8335,7 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v, in
user->ha = ast_append_ha(v->name, v->value, user->ha);
} else if (!strcasecmp(v->name, "setvar")) {
varname = ast_strdupa(v->value);
if ((varval = strchr(varname,'='))) {
if (varname && (varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if((tmpvar = ast_variable_new(varname, varval))) {
@ -9161,7 +9174,10 @@ static char *function_iaxpeer(struct ast_channel *chan, char *cmd, char *data, c
char *peername, *colname;
char iabuf[INET_ADDRSTRLEN];
peername = ast_strdupa(data);
if (!(peername = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Memory Error!\n");
return ret;
}
/* if our channel, return the IP address of the endpoint of current channel */
if (!strcmp(peername,"CURRENTCHANNEL")) {

View File

@ -1860,9 +1860,12 @@ static int create_addr_from_peer(struct sip_pvt *r, struct sip_peer *peer)
char *tmpcall;
char *c;
tmpcall = ast_strdupa(r->callid);
if ((c = strchr(tmpcall, '@'))) {
*c = '\0';
ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
if (tmpcall) {
c = strchr(tmpcall, '@');
if (c) {
*c = '\0';
ast_string_field_build(r, callid, "%s@%s", tmpcall, peer->fromdomain);
}
}
}
if (ast_strlen_zero(r->tohost)) {
@ -7054,8 +7057,12 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
if ((c = strchr(of, ':')))
*c = '\0';
tmp = ast_strdupa(of);
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
if (tmp) {
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
} else {
ast_string_field_set(p, cid_num, of);
}
}
if (ast_strlen_zero(of))
return 0;
@ -7080,8 +7087,12 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
tmp = ast_strdupa(rpid_num);
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
if (tmp) {
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
} else {
ast_string_field_set(p, cid_num, rpid_num);
}
}
if (p->rtp) {
@ -7108,8 +7119,12 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
ast_string_field_set(p, context, user->context);
if (!ast_strlen_zero(user->cid_num) && !ast_strlen_zero(p->cid_num)) {
char *tmp = ast_strdupa(user->cid_num);
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
if (tmp) {
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
} else {
ast_string_field_set(p, cid_num, user->cid_num);
}
}
if (!ast_strlen_zero(user->cid_name) && !ast_strlen_zero(p->cid_num))
ast_string_field_set(p, cid_name, user->cid_name);
@ -7171,8 +7186,12 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
char *tmp = ast_strdupa(rpid_num);
if (*calleridname)
ast_string_field_set(p, cid_name, calleridname);
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
if (tmp) {
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
} else {
ast_string_field_set(p, cid_num, rpid_num);
}
}
if (p->rtp) {
ast_log(LOG_DEBUG, "Setting NAT on RTP to %d\n", (ast_test_flag(p, SIP_NAT) & SIP_NAT_ROUTE));
@ -7217,8 +7236,12 @@ static int check_user_full(struct sip_pvt *p, struct sip_request *req, int sipme
}
if (!ast_strlen_zero(peer->cid_num) && !ast_strlen_zero(p->cid_num)) {
char *tmp = ast_strdupa(peer->cid_num);
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
if (tmp) {
ast_shrink_phone_number(tmp);
ast_string_field_set(p, cid_num, tmp);
} else {
ast_string_field_set(p, cid_num, peer->cid_num);
}
}
if (!ast_strlen_zero(peer->cid_name) && !ast_strlen_zero(p->cid_name))
ast_string_field_set(p, cid_name, peer->cid_name);
@ -9269,7 +9292,10 @@ static char *function_sippeer(struct ast_channel *chan, char *cmd, char *data, c
char *peername, *colname;
char iabuf[INET_ADDRSTRLEN];
peername = ast_strdupa(data);
if (!(peername = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Memory Error!\n");
return ret;
}
if ((colname = strchr(peername, ':'))) {
*colname = '\0';
@ -11927,7 +11953,7 @@ static struct sip_user *build_user(const char *name, struct ast_variable *v, int
ast_copy_string(user->subscribecontext, v->value, sizeof(user->subscribecontext));
} else if (!strcasecmp(v->name, "setvar")) {
varname = ast_strdupa(v->value);
if ((varval = strchr(varname,'='))) {
if (varname && (varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if ((tmpvar = ast_variable_new(varname, varval))) {
@ -12231,7 +12257,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v, int
} else if (!strcasecmp(v->name, "setvar")) {
/* Set peer channel variable */
varname = ast_strdupa(v->value);
if ((varval = strchr(varname,'='))) {
if (varname && (varval = strchr(varname,'='))) {
*varval = '\0';
varval++;
if ((tmpvar = ast_variable_new(varname, varval))) {
@ -12822,6 +12848,10 @@ static int sip_sipredirect(struct sip_pvt *p, const char *dest)
char tmp[80];
cdest = ast_strdupa(dest);
if (!cdest) {
ast_log(LOG_ERROR, "Problem allocating the memory\n");
return 0;
}
extension = strsep(&cdest, "@");
host = strsep(&cdest, ":");
port = strsep(&cdest, ":");
@ -12839,17 +12869,28 @@ static int sip_sipredirect(struct sip_pvt *p, const char *dest)
return 0;
}
if ((localtmp = strstr(tmp, "sip:")) && (localtmp = strchr(localtmp, '@'))) {
char lhost[80] = "", lport[80] = "";
char lhost[80], lport[80];
memset(lhost, 0, sizeof(lhost));
memset(lport, 0, sizeof(lport));
localtmp++;
/* This is okey because lhost and lport are as big as tmp */
sscanf(localtmp, "%[^<>:; ]:%[^<>:; ]", lhost, lport);
if (ast_strlen_zero(lhost)) {
if (!strlen(lhost)) {
ast_log(LOG_ERROR, "Can't find the host address\n");
return 0;
}
host = ast_strdupa(lhost);
if (!ast_strlen_zero(lport))
if (!host) {
ast_log(LOG_ERROR, "Problem allocating the memory\n");
return 0;
}
if (!ast_strlen_zero(lport)) {
port = ast_strdupa(lport);
if (!port) {
ast_log(LOG_ERROR, "Problem allocating the memory\n");
return 0;
}
}
}
}

View File

@ -64,6 +64,10 @@ static char *builtin_function_cdr_read(struct ast_channel *chan, char *cmd, char
return NULL;
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
return NULL;
}
AST_STANDARD_APP_ARGS(args, parse);
@ -89,6 +93,10 @@ static void builtin_function_cdr_write(struct ast_channel *chan, char *cmd, char
return;
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
return;
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -83,7 +83,10 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
return ERROR_NOARG;
}
strings = ast_strdupa(data);
strings = ast_strdupa((char *)data);
if (!strings) {
return ERROR_NOMEM;
}
for (ptrkey = strings; *ptrkey; ptrkey++) {
if (*ptrkey == '|') {
@ -140,6 +143,10 @@ static int cut_internal(struct ast_channel *chan, char *data, char *buffer, size
memset(buffer, 0, buflen);
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
return ERROR_NOMEM;
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -55,7 +55,10 @@ static char *builtin_function_iftime(struct ast_channel *chan, char *cmd, char *
char *iftrue;
char *iffalse;
data = ast_strdupa(data);
if (!(data = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
return NULL;
}
data = ast_strip_quoted(data, "\"", "\"");
expr = strsep(&data, "?");
@ -92,7 +95,10 @@ static char *builtin_function_if(struct ast_channel *chan, char *cmd, char *data
char *iftrue;
char *iffalse;
data = ast_strdupa(data);
if (!(data = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
return NULL;
}
data = ast_strip_quoted(data, "\"", "\"");
expr = strsep(&data, "?");
@ -123,7 +129,10 @@ static char *builtin_function_set(struct ast_channel *chan, char *cmd, char *dat
char *varname;
char *val;
data = ast_strdupa(data);
if (!(data = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Memory Error!\n");
return NULL;
}
varname = strsep(&data, "=");
val = data;

View File

@ -89,6 +89,10 @@ static char *builtin_function_math(struct ast_channel *chan, char *cmd, char *da
}
parse = ast_strdupa(data);
if(!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
return NULL;
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -68,6 +68,10 @@ static char *builtin_function_checkmd5(struct ast_channel *chan, char *cmd, char
}
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory!\n");
return NULL;
}
AST_STANDARD_APP_ARGS(args, parse);

View File

@ -108,6 +108,12 @@ static void acf_odbc_write(struct ast_channel *chan, char *cmd, char *data, cons
t = "";
}
if (!s || !t) {
ast_log(LOG_ERROR, "Out of memory\n");
ast_mutex_unlock(&query_lock);
return;
}
/* XXX You might be tempted to change this section into using
* pbx_builtin_pushvar_helper(). However, note that if you try
* to set a NULL (like for VALUE), then nothing gets set, and the
@ -260,6 +266,11 @@ static char *acf_odbc_read(struct ast_channel *chan, char *cmd, char *data, char
/* Parse our arguments */
s = ast_strdupa(data);
if (!s) {
ast_log(LOG_ERROR, "Out of memory\n");
ast_mutex_unlock(&query_lock);
return "";
}
while ((arg = strsep(&s, "|"))) {
count++;

View File

@ -55,7 +55,12 @@ static char *acf_rand_exec(struct ast_channel *chan, char *cmd, char *data, char
LOCAL_USER_ACF_ADD(u);
s = ast_strdupa(data);
if (!(s = ast_strdupa(data))) {
ast_log(LOG_WARNING, "Out of memory\n");
*buffer = '\0';
LOCAL_USER_REMOVE(u);
return buffer;
}
ast_app_separate_args(s, '|', args, sizeof(args) / sizeof(args[0]));

View File

@ -52,6 +52,11 @@ static char *function_fieldqty(struct ast_channel *chan, char *cmd, char *data,
);
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory\n");
ast_copy_string(buf, "0", len);
return buf;
}
AST_STANDARD_APP_ARGS(args, parse);
if (args.delim) {
@ -86,6 +91,10 @@ static char *builtin_function_filter(struct ast_channel *chan, char *cmd, char *
char *outbuf=buf;
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory");
return "";
}
AST_STANDARD_APP_ARGS(args, parse);
@ -132,6 +141,10 @@ static char *builtin_function_regex(struct ast_channel *chan, char *cmd, char *d
ast_copy_string(buf, "0", len);
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory in %s(%s)\n", cmd, data);
return buf;
}
AST_NONSTANDARD_APP_ARGS(args, parse, '"');
@ -172,6 +185,10 @@ static void builtin_function_array(struct ast_channel *chan, char *cmd, char *da
var = ast_strdupa(data);
value2 = ast_strdupa(value);
if (!var || !value2) {
ast_log(LOG_ERROR, "Out of memory\n");
return;
}
/* The functions this will generally be used with are SORT and ODBC_*, which
* both return comma-delimited lists. However, if somebody uses literal lists,
@ -260,6 +277,10 @@ static char *acf_strftime(struct ast_channel *chan, char *cmd, char *data, char
}
parse = ast_strdupa(data);
if (!parse) {
ast_log(LOG_ERROR, "Out of memory\n");
return buf;
}
AST_STANDARD_APP_ARGS(args, parse);