Clean up and ensure proper usage of alloca()

This replaces all calls to alloca() with ast_alloca() which calls gcc's
__builtin_alloca() to avoid BSD semantics and removes all NULL checks
on memory allocated via ast_alloca() and ast_strdupa().

(closes issue ASTERISK-20125)
Review: https://reviewboard.asterisk.org/r/2032/
Patch-by: Walter Doekes (wdoekes)
........

Merged revisions 370642 from http://svn.asterisk.org/svn/asterisk/branches/1.8


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/10@370643 65c4cc65-6c06-0410-ace0-fbb531ad65f3
10
Kinsey Moore 13 years ago
parent df5ca197ba
commit 7135c1ccba

@ -295,7 +295,7 @@ static int aMYSQL_set(struct ast_channel *chan, char *data)
AST_NONSTANDARD_APP_ARGS(args, data, ' ');
if (args.argc == 3) {
var = alloca(6 + strlen(args.variable) + 1);
var = ast_alloca(6 + strlen(args.variable) + 1);
sprintf(var, "MYSQL_%s", args.variable);
/* Make the parameter case-insensitive */

@ -557,7 +557,7 @@ static char *handle_cli_mobile_search(struct ast_cli_entry *e, int cmd, struct a
max_rsp = 255;
flags = IREQ_CACHE_FLUSH;
ii = alloca(max_rsp * sizeof(inquiry_info));
ii = ast_alloca(max_rsp * sizeof(inquiry_info));
num_rsp = hci_inquiry(adapter->dev_id, len, max_rsp, NULL, &ii, flags);
if (num_rsp > 0) {
ast_cli(a->fd, FORMAT1, "Address", "Name", "Usable", "Type", "Port");

@ -144,7 +144,7 @@ static struct mysql_conn *find_database(const char *database, int for_write)
if (for_write) {
whichdb = ast_strdupa(ptr + 1);
} else {
whichdb = alloca(ptr - database + 1);
whichdb = ast_alloca(ptr - database + 1);
strncpy(whichdb, database, ptr - database);
whichdb[ptr - database] = '\0';
}
@ -467,7 +467,7 @@ static struct ast_config *realtime_multi_mysql(const char *database, const char
}
initfield = ast_strdupa(newparam);
if (initfield && (op = strchr(initfield, ' '))) {
if ((op = strchr(initfield, ' '))) {
*op = '\0';
}

@ -150,7 +150,7 @@ static int dictate_exec(struct ast_channel *chan, const char *data)
ast_mkdir(base, 0755);
len = strlen(base) + strlen(filein) + 2;
if (!path || len > maxlen) {
path = alloca(len);
path = ast_alloca(len);
memset(path, 0, len);
maxlen = len;
} else {

@ -158,7 +158,7 @@ static struct ast_channel *my_ast_get_channel_by_name_locked(const char *channam
* debugging.
*/
pickup_args.len = strlen(channame) + 1;
chkchan = alloca(pickup_args.len + 1);
chkchan = ast_alloca(pickup_args.len + 1);
strcpy(chkchan, channame);
strcat(chkchan, "-");
pickup_args.name = chkchan;

@ -344,12 +344,12 @@ static int festival_exec(struct ast_channel *chan, const char *vdata)
const char *endcmd = "\" 'file)(quit)\n";
strln = strlen(startcmd) + strlen(args.text) + strlen(endcmd) + 1;
newfestivalcommand = alloca(strln);
newfestivalcommand = ast_alloca(strln);
snprintf(newfestivalcommand, strln, "%s%s%s", startcmd, args.text, endcmd);
festivalcommand = newfestivalcommand;
} else { /* This else parses the festivalcommand that we're sent from the config file for \n's, etc */
int x, j;
newfestivalcommand = alloca(strlen(festivalcommand) + strlen(args.text) + 1);
newfestivalcommand = ast_alloca(strlen(festivalcommand) + strlen(args.text) + 1);
for (x = 0, j = 0; x < strlen(festivalcommand); x++) {
if (festivalcommand[x] == '\\' && festivalcommand[x + 1] == 'n') {

@ -76,7 +76,7 @@ static int cpeid_exec(struct ast_channel *chan, const char *idata)
unsigned int x;
for (x = 0; x < 4; x++)
data[x] = alloca(80);
data[x] = ast_alloca(80);
strcpy(data[0], "** CPE Info **");
strcpy(data[1], "Identifying CPE...");

@ -596,8 +596,7 @@ static int macroif_exec(struct ast_channel *chan, const char *data)
char *expr = NULL, *label_a = NULL, *label_b = NULL;
int res = 0;
if (!(expr = ast_strdupa(data)))
return -1;
expr = ast_strdupa(data);
if ((label_a = strchr(expr, '?'))) {
*label_a = '\0';

@ -4197,8 +4197,7 @@ static int count_exec(struct ast_channel *chan, const char *data)
return -1;
}
if (!(localdata = ast_strdupa(data)))
return -1;
localdata = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, localdata);

@ -2054,10 +2054,6 @@ static int minivm_mwi_exec(struct ast_channel *chan, const char *data)
return -1;
}
tmpptr = ast_strdupa((char *)data);
if (!tmpptr) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
if (argc < 4) {
ast_log(LOG_ERROR, "%d arguments passed to MiniVM_MWI, need 4.\n", argc);
@ -2102,10 +2098,6 @@ static int minivm_notify_exec(struct ast_channel *chan, const char *data)
return -1;
}
tmpptr = ast_strdupa((char *)data);
if (!tmpptr) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
if (argc == 2 && !ast_strlen_zero(argv[1]))
@ -2186,10 +2178,6 @@ static int minivm_record_exec(struct ast_channel *chan, const char *data)
return -1;
}
tmp = ast_strdupa((char *)data);
if (!tmp) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
argc = ast_app_separate_args(tmp, ',', argv, ARRAY_LEN(argv));
if (argc == 2) {
if (ast_app_parse_options(minivm_app_options, &flags, opts, argv[1])) {
@ -2249,10 +2237,6 @@ static int minivm_greet_exec(struct ast_channel *chan, const char *data)
return -1;
}
tmpptr = ast_strdupa((char *)data);
if (!tmpptr) {
ast_log(LOG_ERROR, "Out of memory\n");
return -1;
}
argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
if (argc == 2) {
@ -2476,14 +2460,9 @@ static int minivm_accmess_exec(struct ast_channel *chan, const char *data)
if (ast_strlen_zero(data)) {
ast_log(LOG_ERROR, "MinivmAccmess needs at least two arguments: account and option\n");
error = TRUE;
} else
} else {
tmpptr = ast_strdupa((char *)data);
if (!error) {
if (!tmpptr) {
ast_log(LOG_ERROR, "Out of memory\n");
error = TRUE;
} else
argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
argc = ast_app_separate_args(tmpptr, ',', argv, ARRAY_LEN(argv));
}
if (argc <=1) {
@ -2623,7 +2602,7 @@ static int create_vmaccount(char *name, struct ast_variable *var, int realtime)
char *varname = ast_strdupa(var->value);
struct ast_variable *tmpvar;
if (varname && (varval = strchr(varname, '='))) {
if ((varval = strchr(varname, '='))) {
*varval = '\0';
varval++;
if ((tmpvar = ast_variable_new(varname, varval, ""))) {
@ -2681,11 +2660,6 @@ static int timezone_add(const char *zonename, const char *config)
return 0;
msg_format = ast_strdupa(config);
if (msg_format == NULL) {
ast_log(LOG_WARNING, "Out of memory.\n");
ast_free(newzone);
return 0;
}
timezone_str = strsep(&msg_format, "|");
if (!msg_format) {
@ -3201,10 +3175,7 @@ static int minivm_account_func_read(struct ast_channel *chan, const char *cmd, c
struct minivm_account *vmu;
char *username, *domain, *colname;
if (!(username = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Memory Error!\n");
return -1;
}
username = ast_strdupa(data);
if ((colname = strchr(username, ':'))) {
*colname = '\0';
@ -3355,10 +3326,8 @@ static int minivm_counter_func_read(struct ast_channel *chan, const char *cmd, c
*buf = '\0';
if (!(username = ast_strdupa(data))) { /* Copy indata to local buffer */
ast_log(LOG_WARNING, "Memory error!\n");
return -1;
}
username = ast_strdupa(data);
if ((countername = strchr(username, ':'))) {
*countername = '\0';
countername++;
@ -3414,10 +3383,7 @@ static int minivm_counter_func_write(struct ast_channel *chan, const char *cmd,
return -1;
change = atoi(value);
if (!(username = ast_strdupa(data))) { /* Copy indata to local buffer */
ast_log(LOG_WARNING, "Memory error!\n");
return -1;
}
username = ast_strdupa(data);
if ((countername = strchr(username, ':'))) {
*countername = '\0';

@ -607,7 +607,7 @@ static char *filename_parse(char *filename, char *buffer, size_t len)
ast_log(LOG_WARNING, "No file name was provided for a file save option.\n");
} else if (filename[0] != '/') {
char *build;
build = alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(filename) + 3);
build = ast_alloca(strlen(ast_config_AST_MONITOR_DIR) + strlen(filename) + 3);
sprintf(build, "%s/%s", ast_config_AST_MONITOR_DIR, filename);
filename = build;
}

@ -2240,10 +2240,7 @@ static int ospauth_exec(
AST_APP_ARG(options);
);
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
return OSP_AST_ERROR;
}
tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
@ -2335,10 +2332,7 @@ static int osplookup_exec(
return OSP_AST_ERROR;
}
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
return OSP_AST_ERROR;
}
tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
@ -2609,10 +2603,7 @@ static int ospnext_exec(
return OSP_AST_ERROR;
}
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
return OSP_AST_ERROR;
}
tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);
@ -2791,10 +2782,7 @@ static int ospfinished_exec(
AST_APP_ARG(options);
);
if (!(tmp = ast_strdupa(data))) {
ast_log(LOG_ERROR, "Out of memory\n");
return OSP_AST_ERROR;
}
tmp = ast_strdupa(data);
AST_STANDARD_APP_ARGS(args, tmp);

@ -1604,7 +1604,7 @@ static int sms_generate(struct ast_channel *chan, void *data, int len, int sampl
samples = MAXSAMPLES;
}
len = samples * sizeof(*buf) + AST_FRIENDLY_OFFSET;
buf = alloca(len);
buf = ast_alloca(len);
f.frametype = AST_FRAME_VOICE;
ast_format_set(&f.subclass.format, __OUT_FMT, 0);

@ -950,7 +950,7 @@ static int inprocess_cmp_fn(void *obj, void *arg, int flags)
static int inprocess_count(const char *context, const char *mailbox, int delta)
{
struct inprocess *i, *arg = alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2);
struct inprocess *i, *arg = ast_alloca(sizeof(*arg) + strlen(context) + strlen(mailbox) + 2);
arg->context = arg->mailbox + strlen(mailbox) + 1;
strcpy(arg->mailbox, mailbox); /* SAFE */
strcpy(arg->context, context); /* SAFE */
@ -1550,10 +1550,10 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
}
value = strstr(tmp, ",");
if (!value) {
new = alloca(strlen(newpassword)+1);
new = ast_alloca(strlen(newpassword)+1);
sprintf(new, "%s", newpassword);
} else {
new = alloca((strlen(value) + strlen(newpassword) + 1));
new = ast_alloca((strlen(value) + strlen(newpassword) + 1));
sprintf(new, "%s%s", newpassword, value);
}
if (!(cat = ast_category_get(cfg, category))) {
@ -1588,7 +1588,7 @@ static void vm_change_password(struct ast_vm_user *vmu, const char *newpassword)
} else {
var = NULL;
}
new = alloca(strlen(newpassword) + 1);
new = ast_alloca(strlen(newpassword) + 1);
sprintf(new, "%s", newpassword);
if (!(cat = ast_category_get(cfg, category))) {
ast_debug(4, "failed to get category!\n");
@ -4189,7 +4189,7 @@ static int vm_delete(char *file)
int txtsize = 0;
txtsize = (strlen(file) + 5)*sizeof(char);
txt = alloca(txtsize);
txt = ast_alloca(txtsize);
/* Sprintf here would safe because we alloca'd exactly the right length,
* but trying to eliminate all sprintf's anyhow
*/
@ -8074,7 +8074,7 @@ static int vm_play_folder_name_gr(struct ast_channel *chan, char *box)
int cmd;
char *buf;
buf = alloca(strlen(box) + 2);
buf = ast_alloca(strlen(box) + 2);
strcpy(buf, box);
strcat(buf, "s");
@ -10804,7 +10804,7 @@ static int append_mailbox(const char *context, const char *box, const char *data
read_password_from_file(secretfn, vmu->password, sizeof(vmu->password));
}
mailbox_full = alloca(strlen(box) + strlen(context) + 1);
mailbox_full = ast_alloca(strlen(box) + strlen(context) + 1);
strcpy(mailbox_full, box);
strcat(mailbox_full, "@");
strcat(mailbox_full, context);

@ -236,7 +236,7 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
condition = ast_strdupa(data);
size = strlen(chan->context) + strlen(chan->exten) + 32;
my_name = alloca(size);
my_name = ast_alloca(size);
memset(my_name, 0, size);
snprintf(my_name, size, "%s_%s_%d", chan->context, chan->exten, chan->priority);
@ -281,7 +281,7 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
if (!end && !while_pri) {
char *goto_str;
size = strlen(chan->context) + strlen(chan->exten) + 32;
goto_str = alloca(size);
goto_str = ast_alloca(size);
memset(goto_str, 0, size);
snprintf(goto_str, size, "%s,%s,%d", chan->context, chan->exten, chan->priority);
pbx_builtin_setvar_helper(chan, varname, goto_str);
@ -293,7 +293,7 @@ static int _while_exec(struct ast_channel *chan, const char *data, int end)
if (! pbx_builtin_getvar_helper(chan, end_varname)) {
char *goto_str;
size = strlen(chan->context) + strlen(chan->exten) + 32;
goto_str = alloca(size);
goto_str = ast_alloca(size);
memset(goto_str, 0, size);
snprintf(goto_str, size, "%s,%s,%d", chan->context, chan->exten, chan->priority+1);
pbx_builtin_setvar_helper(chan, end_varname, goto_str);

@ -535,7 +535,7 @@ static int config_module(int reload)
if (strchr(schemaname, '\\') || strchr(schemaname, '\'')) {
char *tmp = schemaname, *ptr;
ptr = schemaname = alloca(strlen(tmp) * 2 + 1);
ptr = schemaname = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;
@ -548,7 +548,7 @@ static int config_module(int reload)
if (strchr(tablename, '\\') || strchr(tablename, '\'')) {
char *tmp = tablename, *ptr;
ptr = tablename = alloca(strlen(tmp) * 2 + 1);
ptr = tablename = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;

@ -182,7 +182,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
ast_debug(1, "Opening device %s in %s mode\n", dev, (stream == SND_PCM_STREAM_CAPTURE) ? "read" : "write");
}
hwparams = alloca(snd_pcm_hw_params_sizeof());
hwparams = ast_alloca(snd_pcm_hw_params_sizeof());
memset(hwparams, 0, snd_pcm_hw_params_sizeof());
snd_pcm_hw_params_any(handle, hwparams);
@ -223,7 +223,7 @@ static snd_pcm_t *alsa_card_init(char *dev, snd_pcm_stream_t stream)
if (err < 0)
ast_log(LOG_ERROR, "Couldn't set the new hw params: %s\n", snd_strerror(err));
swparams = alloca(snd_pcm_sw_params_sizeof());
swparams = ast_alloca(snd_pcm_sw_params_sizeof());
memset(swparams, 0, snd_pcm_sw_params_sizeof());
snd_pcm_sw_params_current(handle, swparams);

@ -1906,15 +1906,13 @@ static struct ast_channel *gtalk_request(const char *type, struct ast_format_cap
if (data) {
s = ast_strdupa(data);
if (s) {
sender = strsep(&s, "/");
if (sender && (sender[0] != '\0')) {
to = strsep(&s, "/");
}
if (!to) {
ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", (char*) data);
return NULL;
}
sender = strsep(&s, "/");
if (sender && (sender[0] != '\0')) {
to = strsep(&s, "/");
}
if (!to) {
ast_log(LOG_ERROR, "Bad arguments in Gtalk Dialstring: %s\n", (char*) data);
return NULL;
}
}

@ -3114,10 +3114,7 @@ static int try_firmware(char *s)
unsigned char sum[16], buf[1024];
char *s2, *last;
if (!(s2 = alloca(strlen(s) + 100))) {
ast_log(LOG_WARNING, "Alloca failed!\n");
return -1;
}
s2 = ast_alloca(strlen(s) + 100);
last = strrchr(s, '/');
if (last)
@ -6359,7 +6356,7 @@ static int decode_frame(ast_aes_decrypt_key *dcx, struct ast_iax2_full_hdr *fh,
int padding;
unsigned char *workspace;
workspace = alloca(*datalen);
workspace = ast_alloca(*datalen);
memset(f, 0, sizeof(*f));
if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh;
@ -6405,9 +6402,7 @@ static int encrypt_frame(ast_aes_encrypt_key *ecx, struct ast_iax2_full_hdr *fh,
{
int padding;
unsigned char *workspace;
workspace = alloca(*datalen + 32);
if (!workspace)
return -1;
workspace = ast_alloca(*datalen + 32);
if (ntohs(fh->scallno) & IAX_FLAG_FULL) {
struct ast_iax2_full_enc_hdr *efh = (struct ast_iax2_full_enc_hdr *)fh;
if (iaxdebug)
@ -10042,9 +10037,9 @@ static int socket_process(struct iax2_thread *thread)
char *using_prefs = "mine";
/* allocate an iax_frame with 4096 bytes of data buffer */
fr = alloca(sizeof(*fr) + 4096);
fr = ast_alloca(sizeof(*fr) + 4096);
memset(fr, 0, sizeof(*fr));
fr->afdatalen = 4096; /* From alloca() above */
fr->afdatalen = 4096; /* From ast_alloca() above */
/* Copy frequently used parameters to the stack */
res = thread->buf_len;
@ -12427,9 +12422,7 @@ static int peer_set_srcaddr(struct iax2_peer *peer, const char *srcaddr)
char *addr;
char *portstr;
if (!(tmp = ast_strdupa(srcaddr)))
return -1;
tmp = ast_strdupa(srcaddr);
addr = strsep(&tmp, ":");
portstr = tmp;
@ -12891,7 +12884,7 @@ static struct iax2_user *build_user(const char *name, struct ast_variable *v, st
user->ha = ast_append_ha(v->name, v->value, user->ha, NULL);
} else if (!strcasecmp(v->name, "setvar")) {
varname = ast_strdupa(v->value);
if (varname && (varval = strchr(varname,'='))) {
if ((varval = strchr(varname, '='))) {
*varval = '\0';
varval++;
if((tmpvar = ast_variable_new(varname, varval, ""))) {

@ -1551,14 +1551,13 @@ static struct ast_channel *jingle_request(const char *type, struct ast_format_ca
if (data) {
s = ast_strdupa(data);
if (s) {
sender = strsep(&s, "/");
if (sender && (sender[0] != '\0'))
to = strsep(&s, "/");
if (!to) {
ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", (char*) data);
return NULL;
}
sender = strsep(&s, "/");
if (sender && (sender[0] != '\0')) {
to = strsep(&s, "/");
}
if (!to) {
ast_log(LOG_ERROR, "Bad arguments in Jingle Dialstring: %s\n", (char*) data);
return NULL;
}
}

@ -5425,7 +5425,7 @@ static int create_addr_from_peer(struct sip_pvt *dialog, struct sip_peer *peer)
/* Change the dialog callid. */
callid_size = strlen(tmpcall) + strlen(peer->fromdomain) + 2;
new_callid = alloca(callid_size);
new_callid = ast_alloca(callid_size);
snprintf(new_callid, callid_size, "%s@%s", tmpcall, peer->fromdomain);
change_callid_pvt(dialog, new_callid);
}
@ -13137,7 +13137,7 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
cid_num = S_COR(caller->caller.id.number.valid,
caller->caller.id.number.str, "");
need = strlen(cid_num) + strlen(p->fromdomain) + sizeof("sip:@");
remote_target = alloca(need);
remote_target = ast_alloca(need);
snprintf(remote_target, need, "sip:%s@%s", cid_num, p->fromdomain);
remote_display = ast_strdupa(S_COR(caller->caller.id.name.valid,
@ -13146,7 +13146,7 @@ static void state_notify_build_xml(int state, int full, const char *exten, const
connected_num = S_COR(caller->connected.id.number.valid,
caller->connected.id.number.str, "");
need = strlen(connected_num) + strlen(p->fromdomain) + sizeof("sip:@");
local_target = alloca(need);
local_target = ast_alloca(need);
snprintf(local_target, need, "sip:%s@%s", connected_num, p->fromdomain);
local_display = ast_strdupa(S_COR(caller->connected.id.name.valid,
@ -24110,7 +24110,8 @@ static int local_attended_transfer(struct sip_pvt *transferer, struct sip_dual *
payload_size = ast_connected_line_build_data(connected_line_data,
sizeof(connected_line_data), &connected_to_target, NULL);
frame_size = payload_size + sizeof(*frame_payload);
if (payload_size != -1 && (frame_payload = alloca(frame_size))) {
if (payload_size != -1) {
frame_payload = ast_alloca(frame_size);
frame_payload->payload_size = payload_size;
memcpy(frame_payload->payload, connected_line_data, payload_size);
frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO;
@ -30610,7 +30611,7 @@ static int sip_addheader(struct ast_channel *chan, const char *data)
}
if (ok) {
size_t len = strlen(inbuf);
subbuf = alloca(len + 1);
subbuf = ast_alloca(len + 1);
ast_get_encoded_str(inbuf, subbuf, len + 1);
pbx_builtin_setvar_helper(chan, varbuf, subbuf);
if (sipdebug) {

@ -648,7 +648,7 @@ static int func_mchan_read(struct ast_channel *chan, const char *function,
char *data, struct ast_str **buf, ssize_t len)
{
struct ast_channel *mchan = ast_channel_get_by_name(chan->linkedid);
char *template = alloca(4 + strlen(data));
char *template = ast_alloca(4 + strlen(data));
sprintf(template, "${%s}", data); /* SAFE */
ast_str_substitute_variables(buf, len, mchan ? mchan : chan, template);
if (mchan) {

@ -119,7 +119,7 @@ static int sort_internal(struct ast_channel *chan, char *data, char *buffer, siz
count++;
}
sortable_keys = alloca(count * sizeof(struct sortable_keys));
sortable_keys = ast_alloca(count * sizeof(struct sortable_keys));
memset(sortable_keys, 0, count * sizeof(struct sortable_keys));
@ -170,9 +170,8 @@ static int cut_internal(struct ast_channel *chan, char *data, struct ast_str **b
/* Check arguments */
if (args.argc < 3) {
return ERROR_NOARG;
} else if (!(var_expr = alloca(strlen(args.varname) + 4))) {
return ERROR_NOMEM;
}
var_expr = ast_alloca(strlen(args.varname) + 4);
/* Get the value of the variable named in the 1st argument */
snprintf(var_expr, strlen(args.varname) + 4, "${%s}", args.varname);

@ -148,7 +148,7 @@ static int shared_read(struct ast_channel *chan, const char *cmd, char *data, ch
AST_STANDARD_APP_ARGS(args, data);
if (!ast_strlen_zero(args.chan)) {
char *prefix = alloca(strlen(args.chan) + 2);
char *prefix = ast_alloca(strlen(args.chan) + 2);
sprintf(prefix, "%s-", args.chan);
if (!(c_ref = ast_channel_get_by_name(args.chan)) && !(c_ref = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
ast_log(LOG_ERROR, "Channel '%s' not found! Variable '%s' will be blank.\n", args.chan, args.var);
@ -206,7 +206,7 @@ static int shared_write(struct ast_channel *chan, const char *cmd, char *data, c
AST_STANDARD_APP_ARGS(args, data);
if (!ast_strlen_zero(args.chan)) {
char *prefix = alloca(strlen(args.chan) + 2);
char *prefix = ast_alloca(strlen(args.chan) + 2);
sprintf(prefix, "%s-", args.chan);
if (!(c_ref = ast_channel_get_by_name(args.chan)) && !(c_ref = ast_channel_get_by_name_prefix(prefix, strlen(prefix)))) {
ast_log(LOG_ERROR, "Channel '%s' not found! Variable '%s' not set to '%s'.\n", args.chan, args.var, value);

@ -250,17 +250,15 @@ static int import_helper(struct ast_channel *chan, const char *cmd, char *data,
struct ast_channel *chan2;
if ((chan2 = ast_channel_get_by_name(args.channel))) {
char *s = alloca(strlen(args.varname) + 4);
if (s) {
sprintf(s, "${%s}", args.varname);
ast_channel_lock(chan2);
if (buf) {
pbx_substitute_variables_helper(chan2, s, buf, len);
} else {
ast_str_substitute_variables(str, len, chan2, s);
}
ast_channel_unlock(chan2);
char *s = ast_alloca(strlen(args.varname) + 4);
sprintf(s, "${%s}", args.varname);
ast_channel_lock(chan2);
if (buf) {
pbx_substitute_variables_helper(chan2, s, buf, len);
} else {
ast_str_substitute_variables(str, len, chan2, s);
}
ast_channel_unlock(chan2);
chan2 = ast_channel_unref(chan2);
}
}

@ -456,7 +456,7 @@ static int function_fieldqty_helper(struct ast_channel *chan, const char *cmd,
if (args.delim) {
ast_get_encoded_char(args.delim, delim, &delim_used);
varsubst = alloca(strlen(args.varname) + 4);
varsubst = ast_alloca(strlen(args.varname) + 4);
sprintf(varsubst, "${%s}", args.varname);
ast_str_substitute_variables(&str, 0, chan, varsubst);
@ -522,7 +522,7 @@ static int function_fieldnum_helper(struct ast_channel *chan, const char *cmd,
ast_log(LOG_ERROR, "Usage: FIELDNUM(<listname>,<delimiter>,<fieldvalue>)\n");
res = -1;
} else {
varsubst = alloca(strlen(args.varname) + 4);
varsubst = ast_alloca(strlen(args.varname) + 4);
sprintf(varsubst, "${%s}", args.varname);
ast_str_substitute_variables(&str, 0, chan, varsubst);
@ -606,7 +606,7 @@ static int listfilter(struct ast_channel *chan, const char *cmd, char *parse, ch
return -1;
}
varsubst = alloca(strlen(args.listname) + 4);
varsubst = ast_alloca(strlen(args.listname) + 4);
sprintf(varsubst, "${%s}", args.listname);
/* If we don't lock the channel, the variable could disappear out from underneath us. */
@ -636,7 +636,7 @@ static int listfilter(struct ast_channel *chan, const char *cmd, char *parse, ch
}
dlen = strlen(args.delimiter);
delim = alloca(dlen + 1);
delim = ast_alloca(dlen + 1);
ast_get_encoded_str(args.delimiter, delim, dlen + 1);
if ((dlen = strlen(delim)) == 0) {
@ -819,7 +819,7 @@ static int replace(struct ast_channel *chan, const char *cmd, char *data, struct
return -1;
}
varsubst = alloca(strlen(args.varname) + 4);
varsubst = ast_alloca(strlen(args.varname) + 4);
sprintf(varsubst, "${%s}", args.varname);
ast_str_substitute_variables(&str, 0, chan, varsubst);
@ -906,7 +906,7 @@ static int strreplace(struct ast_channel *chan, const char *cmd, char *data, str
find_size = strlen(args.find_string);
/* set varsubstr to the matching variable */
varsubstr = alloca(strlen(args.varname) + 4);
varsubstr = ast_alloca(strlen(args.varname) + 4);
sprintf(varsubstr, "${%s}", args.varname);
ast_str_substitute_variables(&str, 0, chan, varsubstr);
@ -1026,9 +1026,10 @@ static int array(struct ast_channel *chan, const char *cmd, char *var,
char *origvar = "", *value2, varname[256];
int i, ishash = 0;
value2 = ast_strdupa(value);
if (!var || !value2)
if (!var) {
return -1;
}
value2 = ast_strdupa(value);
if (!strcmp(cmd, "HASH")) {
const char *var2 = pbx_builtin_getvar_helper(chan, "~ODBCFIELDS~");
@ -1544,7 +1545,7 @@ static int shift_pop(struct ast_channel *chan, const char *cmd, char *data, stru
return -1;
}
varsubst = alloca(strlen(args.var) + 4);
varsubst = ast_alloca(strlen(args.var) + 4);
sprintf(varsubst, "${%s}", args.var);
ast_str_substitute_variables(&before, 0, chan, varsubst);
@ -1608,7 +1609,7 @@ static int unshift_push(struct ast_channel *chan, const char *cmd, char *data, c
ast_get_encoded_char(args.delimiter, delimiter, &unused);
}
varsubst = alloca(strlen(args.var) + 4);
varsubst = ast_alloca(strlen(args.var) + 4);
sprintf(varsubst, "${%s}", args.var);
ast_str_substitute_variables(&previous_value, 0, chan, varsubst);

@ -357,7 +357,7 @@ int ast_get_timeval(const char *src, struct timeval *tv, struct timeval _default
/*! \brief The descriptor of a dynamic string
* XXX storage will be optimized later if needed
* We use the ts field to indicate the type of storage.
* Three special constants indicate malloc, alloca() or static
* Three special constants indicate malloc, ast_alloca() or static
* variables, all other values indicate a
* struct ast_threadstorage pointer.
*/
@ -608,7 +608,7 @@ int ast_str_copy_string(struct ast_str **dst, struct ast_str *src),
#define ast_str_alloca(init_len) \
({ \
struct ast_str *__ast_str_buf; \
__ast_str_buf = alloca(sizeof(*__ast_str_buf) + init_len); \
__ast_str_buf = ast_alloca(sizeof(*__ast_str_buf) + init_len); \
__ast_str_buf->__AST_STR_LEN = init_len; \
__ast_str_buf->__AST_STR_USED = 0; \
__ast_str_buf->__AST_STR_TS = DS_ALLOCA; \

@ -638,13 +638,22 @@ int _ast_vasprintf(char **ret, const char *file, int lineno, const char *func, c
#endif /* AST_DEBUG_MALLOC */
/*!
\brief call __builtin_alloca to ensure we get gcc builtin semantics
\param size The size of the buffer we want allocated
This macro will attempt to allocate memory from the stack. If it fails
you won't get a NULL returned, but a SEGFAULT if you're lucky.
*/
#define ast_alloca(size) __builtin_alloca(size)
#if !defined(ast_strdupa) && defined(__GNUC__)
/*!
\brief duplicate a string in memory from the stack
\param s The string to duplicate
This macro will duplicate the given string. It returns a pointer to the stack
allocatted memory for the new string.
This macro will duplicate the given string. It returns a pointer to stack
allocated memory for the new string.
*/
#define ast_strdupa(s) \
(__extension__ \

@ -594,7 +594,7 @@ int ast_control_streamfile(struct ast_channel *chan, const char *file,
}
if (blen > 2) {
breaks = alloca(blen + 1);
breaks = ast_alloca(blen + 1);
breaks[0] = '\0';
if (stop) {
strcat(breaks, stop);
@ -1340,8 +1340,8 @@ static enum AST_LOCK_RESULT ast_lock_path_lockfile(const char *path)
int lp = strlen(path);
time_t start;
s = alloca(lp + 10);
fs = alloca(lp + 20);
s = ast_alloca(lp + 10);
fs = ast_alloca(lp + 20);
snprintf(fs, strlen(path) + 19, "%s/.lock-%08lx", path, ast_random());
fd = open(fs, O_WRONLY | O_CREAT | O_EXCL, AST_FILE_MODE);
@ -1373,7 +1373,7 @@ static int ast_unlock_path_lockfile(const char *path)
char *s;
int res;
s = alloca(strlen(path) + 10);
s = ast_alloca(strlen(path) + 10);
snprintf(s, strlen(path) + 9, "%s/%s", path, ".lock");
@ -1414,7 +1414,7 @@ static enum AST_LOCK_RESULT ast_lock_path_flock(const char *path)
struct path_lock *pl;
struct stat st, ost;
fs = alloca(strlen(path) + 20);
fs = ast_alloca(strlen(path) + 20);
snprintf(fs, strlen(path) + 19, "%s/lock", path);
if (lstat(fs, &st) == 0) {
@ -1495,7 +1495,7 @@ static int ast_unlock_path_flock(const char *path)
char *s;
struct path_lock *p;
s = alloca(strlen(path) + 20);
s = ast_alloca(strlen(path) + 20);
AST_LIST_LOCK(&path_lock_list);
AST_LIST_TRAVERSE_SAFE_BEGIN(&path_lock_list, p, le) {

@ -2815,7 +2815,7 @@ static void ast_remotecontrol(char *data)
}
if (data) {
char prefix[] = "cli quit after ";
char *tmp = alloca(strlen(data) + strlen(prefix) + 1);
char *tmp = ast_alloca(strlen(data) + strlen(prefix) + 1);
sprintf(tmp, "%s%s", prefix, data);
if (write(ast_consock, tmp, strlen(tmp) + 1) < 0) {
ast_log(LOG_ERROR, "write() failed: %s\n", strerror(errno));

@ -430,7 +430,7 @@ static char *handle_memory_show_summary(struct ast_cli_entry *e, int cmd, struct
break;
}
if (!cur) {
cur = alloca(sizeof(*cur));
cur = ast_alloca(sizeof(*cur));
memset(cur, 0, sizeof(*cur));
ast_copy_string(cur->fn, fn ? reg->func : reg->file, sizeof(cur->fn));
cur->next = list;

@ -314,7 +314,7 @@ int callerid_feed_jp(struct callerid_state *cid, unsigned char *ubuf, int len, s
int x;
short *buf;
buf = alloca(2 * len + cid->oldlen);
buf = ast_alloca(2 * len + cid->oldlen);
memcpy(buf, cid->oldstuff, cid->oldlen);
mylen += cid->oldlen / 2;
@ -552,7 +552,7 @@ int callerid_feed(struct callerid_state *cid, unsigned char *ubuf, int len, stru
int x;
short *buf;
buf = alloca(2 * len + cid->oldlen);
buf = ast_alloca(2 * len + cid->oldlen);
memcpy(buf, cid->oldstuff, cid->oldlen);
mylen += cid->oldlen/2;

@ -3209,8 +3209,8 @@ struct ast_channel *ast_waitfor_nandfds(struct ast_channel **c, int n, int *fds,
*exception = 0;
if ((sz = n * AST_MAX_FDS + nfds)) {
pfds = alloca(sizeof(*pfds) * sz);
fdmap = alloca(sizeof(*fdmap) * sz);
pfds = ast_alloca(sizeof(*pfds) * sz);
fdmap = ast_alloca(sizeof(*fdmap) * sz);
} else {
/* nothing to allocate and no FDs to check */
return NULL;
@ -6619,7 +6619,7 @@ static void masquerade_colp_transfer(struct ast_channel *transferee, struct xfer
sizeof(connected_line_data), &colp->target_id, NULL);
if (payload_size != -1) {
frame_size = payload_size + sizeof(*frame_payload);
frame_payload = alloca(frame_size);
frame_payload = ast_alloca(frame_size);
frame_payload->action = AST_FRAME_READ_ACTION_CONNECTED_LINE_MACRO;
frame_payload->payload_size = payload_size;
memcpy(frame_payload->payload, connected_line_data, payload_size);

@ -116,7 +116,7 @@ static void CB_ADD(struct ast_str **cb, const char *str)
static void CB_ADD_LEN(struct ast_str **cb, const char *str, int len)
{
char *s = alloca(len + 1);
char *s = ast_alloca(len + 1);
ast_copy_string(s, str, len);
ast_str_append(cb, 0, "%s", str);
}
@ -2910,7 +2910,7 @@ static char *handle_cli_config_reload(struct ast_cli_entry *e, int cmd, struct a
AST_LIST_LOCK(&cfmtime_head);
AST_LIST_TRAVERSE(&cfmtime_head, cfmtime, list) {
if (!strcmp(cfmtime->filename, a->argv[2])) {
char *buf = alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1);
char *buf = ast_alloca(strlen("module reload ") + strlen(cfmtime->who_asked) + 1);
sprintf(buf, "module reload %s", cfmtime->who_asked);
ast_cli_command(a->fd, buf);
}

@ -192,7 +192,7 @@ static int db_open(void)
char *dbname;
struct stat dont_care;
if (!(dbname = alloca(strlen(ast_config_AST_DB) + sizeof(".sqlite3")))) {
if (!(dbname = ast_alloca(strlen(ast_config_AST_DB) + sizeof(".sqlite3")))) {
return -1;
}
strcpy(dbname, ast_config_AST_DB);

@ -1334,13 +1334,13 @@ static int ast_dsp_silence_noise_with_energy(struct ast_dsp *dsp, struct ast_fra
len = f->datalen;
switch (f->subclass.format.id) {
case AST_FORMAT_ULAW:
s = alloca(len * 2);
s = ast_alloca(len * 2);
for (x = 0;x < len; x++) {
s[x] = AST_MULAW(odata[x]);
}
break;
case AST_FORMAT_ALAW:
s = alloca(len * 2);
s = ast_alloca(len * 2);
for (x = 0;x < len; x++) {
s[x] = AST_ALAW(odata[x]);
}
@ -1404,13 +1404,13 @@ struct ast_frame *ast_dsp_process(struct ast_channel *chan, struct ast_dsp *dsp,
switch (af->subclass.format.id) {
case AST_FORMAT_ULAW:
case AST_FORMAT_TESTLAW:
shortdata = alloca(af->datalen * 2);
shortdata = ast_alloca(af->datalen * 2);
for (x = 0;x < len; x++) {
shortdata[x] = AST_MULAW(odata[x]);
}
break;
case AST_FORMAT_ALAW:
shortdata = alloca(af->datalen * 2);
shortdata = ast_alloca(af->datalen * 2);
for (x = 0; x < len; x++) {
shortdata[x] = AST_ALAW(odata[x]);
}

@ -474,7 +474,7 @@ enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type typ
ie_type != AST_EVENT_IE_END;
ie_type = va_arg(ap, enum ast_event_ie_type))
{
struct ast_event_ie_val *ie_value = alloca(sizeof(*ie_value));
struct ast_event_ie_val *ie_value = ast_alloca(sizeof(*ie_value));
int insert = 0;
memset(ie_value, 0, sizeof(*ie_value));
@ -498,7 +498,7 @@ enum ast_event_subscriber_res ast_event_check_subscriber(enum ast_event_type typ
void *data = va_arg(ap, void *);
size_t datalen = va_arg(ap, size_t);
ie_value->payload.raw = alloca(datalen);
ie_value->payload.raw = ast_alloca(datalen);
memcpy(ie_value->payload.raw, data, datalen);
ie_value->raw_datalen = datalen;
insert = 1;
@ -1147,7 +1147,7 @@ int ast_event_append_ie_str(struct ast_event **event, enum ast_event_ie_type ie_
size_t payload_len;
payload_len = sizeof(*str_payload) + strlen(str);
str_payload = alloca(payload_len);
str_payload = ast_alloca(payload_len);
strcpy(str_payload->str, str);
if (ie_type == AST_EVENT_IE_DEVICE) {
@ -1220,7 +1220,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
ie_type != AST_EVENT_IE_END;
ie_type = va_arg(ap, enum ast_event_ie_type))
{
struct ast_event_ie_val *ie_value = alloca(sizeof(*ie_value));
struct ast_event_ie_val *ie_value = ast_alloca(sizeof(*ie_value));
int insert = 0;
memset(ie_value, 0, sizeof(*ie_value));
@ -1243,7 +1243,7 @@ struct ast_event *ast_event_new(enum ast_event_type type, ...)
{
void *data = va_arg(ap, void *);
size_t datalen = va_arg(ap, size_t);
ie_value->payload.raw = alloca(datalen);
ie_value->payload.raw = ast_alloca(datalen);
memcpy(ie_value->payload.raw, data, datalen);
ie_value->raw_datalen = datalen;
insert = 1;

@ -716,7 +716,7 @@ static void set_new_chan_name(struct ast_channel *chan)
ast_channel_lock(chan);
seq_num = ast_atomic_fetchadd_int(&seq_num_last, +1);
len = snprintf(dummy, sizeof(dummy), "%s<XFER_%x>", chan->name, seq_num) + 1;
chan_name = alloca(len);
chan_name = ast_alloca(len);
snprintf(chan_name, len, "%s<XFER_%x>", chan->name, seq_num);
ast_channel_unlock(chan);
@ -2111,8 +2111,8 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
if (touch_monitor) {
len = strlen(touch_monitor) + 50;
args = alloca(len);
touch_filename = alloca(len);
args = ast_alloca(len);
touch_filename = ast_alloca(len);
snprintf(touch_filename, len, "%s-%ld-%s", S_OR(touch_monitor_prefix, "auto"), (long)time(NULL), touch_monitor);
snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename);
} else {
@ -2121,8 +2121,8 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee
callee_chan_id = ast_strdupa(S_COR(callee_chan->caller.id.number.valid,
callee_chan->caller.id.number.str, callee_chan->name));
len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
args = alloca(len);
touch_filename = alloca(len);
args = ast_alloca(len);
touch_filename = ast_alloca(len);
snprintf(touch_filename, len, "%s-%ld-%s-%s", S_OR(touch_monitor_prefix, "auto"), (long)time(NULL), caller_chan_id, callee_chan_id);
snprintf(args, len, "%s,%s,m", S_OR(touch_format, "wav"), touch_filename);
}
@ -2223,8 +2223,8 @@ static int builtin_automixmonitor(struct ast_channel *chan, struct ast_channel *
if (touch_monitor) {
len = strlen(touch_monitor) + 50;
args = alloca(len);
touch_filename = alloca(len);
args = ast_alloca(len);
touch_filename = ast_alloca(len);
snprintf(touch_filename, len, "auto-%ld-%s", (long)time(NULL), touch_monitor);
snprintf(args, len, "%s.%s,b", touch_filename, (touch_format) ? touch_format : "wav");
} else {
@ -2233,8 +2233,8 @@ static int builtin_automixmonitor(struct ast_channel *chan, struct ast_channel *
callee_chan_id = ast_strdupa(S_COR(callee_chan->caller.id.number.valid,
callee_chan->caller.id.number.str, callee_chan->name));
len = strlen(caller_chan_id) + strlen(callee_chan_id) + 50;
args = alloca(len);
touch_filename = alloca(len);
args = ast_alloca(len);
touch_filename = ast_alloca(len);
snprintf(touch_filename, len, "auto-%ld-%s-%s", (long)time(NULL), caller_chan_id, callee_chan_id);
snprintf(args, len, "%s.%s,b", touch_filename, S_OR(touch_format, "wav"));
}
@ -3560,7 +3560,7 @@ static struct ast_channel *feature_request_and_dial(struct ast_channel *caller,
disconnect_code = builtin_features[x].exten;
len = strlen(disconnect_code) + 1;
dialed_code = alloca(len);
dialed_code = ast_alloca(len);
memset(dialed_code, 0, len);
break;
}

@ -689,9 +689,7 @@ struct ast_filestream *ast_openstream_full(struct ast_channel *chan, const char
if (preflang == NULL)
preflang = "";
buflen = strlen(preflang) + strlen(filename) + 4;
buf = alloca(buflen);
if (buf == NULL)
return NULL;
buf = ast_alloca(buflen);
if (!(file_fmt_cap = ast_format_cap_alloc_nolock())) {
return NULL;
@ -735,9 +733,7 @@ struct ast_filestream *ast_openvstream(struct ast_channel *chan, const char *fil
if (preflang == NULL)
preflang = "";
buflen = strlen(preflang) + strlen(filename) + 4;
buf = alloca(buflen);
if (buf == NULL)
return NULL;
buf = ast_alloca(buflen);
/* is the channel capable of video without translation ?*/
if (!ast_format_cap_has_type(chan->nativeformats, AST_FORMAT_TYPE_VIDEO)) {
@ -990,9 +986,7 @@ int ast_fileexists(const char *filename, const char *fmt, const char *preflang)
if (preflang == NULL)
preflang = "";
buflen = strlen(preflang) + strlen(filename) + 4; /* room for everything */
buf = alloca(buflen);
if (buf == NULL)
return 0;
buf = ast_alloca(buflen);
return fileexists_core(filename, fmt, preflang, buf, buflen, NULL) ? 1 : 0;
}
@ -1171,7 +1165,7 @@ struct ast_filestream *ast_writefile(const char *filename, const char *type, con
*c = '_';
size = strlen(fn) + strlen(record_cache_dir) + 2;
buf = alloca(size);
buf = ast_alloca(size);
strcpy(buf, record_cache_dir);
strcat(buf, "/");
strcat(buf, fn);

@ -251,7 +251,7 @@ static int static_callback(struct ast_tcptls_session_instance *ser,
goto out403;
}
path = alloca(len);
path = ast_alloca(len);
sprintf(path, "%s/static-http/%s", ast_config_AST_DATA_DIR, uri);
if (stat(path, &st)) {
goto out404;
@ -624,9 +624,7 @@ struct ast_variable *ast_http_get_post_vars(
return NULL;
}
if (!(buf = alloca(content_length))) {
return NULL;
}
buf = ast_alloca(content_length);
if (!fgets(buf, content_length, ser->f)) {
return NULL;
}
@ -767,7 +765,7 @@ cleanup:
static HOOK_T ssl_write(void *cookie, const char *buf, LEN_T len)
{
#if 0
char *s = alloca(len+1);
char *s = ast_alloca(len+1);
strncpy(s, buf, len);
s[len] = '\0';
ast_verbose("ssl write size %d <%s>\n", (int)len, s);

@ -1504,11 +1504,11 @@ void __ast_verbose_ap(const char *file, int line, const char *func, const char *
now = ast_tvnow();
ast_localtime(&now, &tm, NULL);
ast_strftime(date, sizeof(date), dateformat, &tm);
datefmt = alloca(strlen(date) + 3 + strlen(fmt) + 1);
datefmt = ast_alloca(strlen(date) + 3 + strlen(fmt) + 1);
sprintf(datefmt, "%c[%s] %s", 127, date, fmt);
fmt = datefmt;
} else {
char *tmp = alloca(strlen(fmt) + 2);
char *tmp = ast_alloca(strlen(fmt) + 2);
sprintf(tmp, "%c%s", 127, fmt);
fmt = tmp;
}

@ -2625,7 +2625,7 @@ static void astman_append_json(struct mansession *s, const char *str)
{
char *buf;
buf = alloca(2 * strlen(str) + 1);
buf = ast_alloca(2 * strlen(str) + 1);
json_escape(buf, str);
astman_append(s, "%s", buf);
}

@ -4172,7 +4172,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
whereweare += (len + 3);
if (!var)
var = alloca(VAR_BUF_SIZE);
var = ast_alloca(VAR_BUF_SIZE);
/* Store variable name (and truncate) */
ast_copy_string(var, vars, len + 1);
@ -4181,7 +4181,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
if (needsub) {
size_t used;
if (!ltmp)
ltmp = alloca(VAR_BUF_SIZE);
ltmp = ast_alloca(VAR_BUF_SIZE);
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &used);
vars = ltmp;
@ -4190,7 +4190,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
}
if (!workspace)
workspace = alloca(VAR_BUF_SIZE);
workspace = ast_alloca(VAR_BUF_SIZE);
workspace[0] = '\0';
@ -4261,7 +4261,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
whereweare += (len + 3);
if (!var)
var = alloca(VAR_BUF_SIZE);
var = ast_alloca(VAR_BUF_SIZE);
/* Store variable name (and truncate) */
ast_copy_string(var, vars, len + 1);
@ -4270,7 +4270,7 @@ void pbx_substitute_variables_helper_full(struct ast_channel *c, struct varshead
if (needsub) {
size_t used;
if (!ltmp)
ltmp = alloca(VAR_BUF_SIZE);
ltmp = ast_alloca(VAR_BUF_SIZE);
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1, &used);
vars = ltmp;
@ -4579,7 +4579,7 @@ static int handle_statechange(void *datap)
return -1;
}
cmpdevice = alloca(sizeof(*cmpdevice) + strlen(sc->dev));
cmpdevice = ast_alloca(sizeof(*cmpdevice) + strlen(sc->dev));
strcpy(cmpdevice->hintdevice, sc->dev);
ast_mutex_lock(&context_merge_lock);/* Hold off ast_merge_contexts_and_delete */
@ -10278,11 +10278,9 @@ int pbx_builtin_importvar(struct ast_channel *chan, const char *data)
if (channel && value && name) { /*! \todo XXX should do !ast_strlen_zero(..) of the args ? */
struct ast_channel *chan2 = ast_channel_get_by_name(channel);
if (chan2) {
char *s = alloca(strlen(value) + 4);
if (s) {
sprintf(s, "${%s}", value);
pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1);
}
char *s = ast_alloca(strlen(value) + 4);
sprintf(s, "${%s}", value);
pbx_substitute_variables_helper(chan2, s, tmp, sizeof(tmp) - 1);
chan2 = ast_channel_unref(chan2);
}
pbx_builtin_setvar_helper(chan, name, tmp);

@ -8312,7 +8312,7 @@ int ast_say_counted_noun(struct ast_channel *chan, int num, const char noun[])
} else { /* English and default */
ending = counted_noun_ending_en(num);
}
temp = alloca((temp_len = (strlen(noun) + strlen(ending) + 1)));
temp = ast_alloca((temp_len = (strlen(noun) + strlen(ending) + 1)));
snprintf(temp, temp_len, "%s%s", noun, ending);
return ast_play_and_wait(chan, temp);
}
@ -8354,7 +8354,7 @@ int ast_say_counted_adjective(struct ast_channel *chan, int num, const char adje
} else { /* English and default */
ending = "";
}
temp = alloca((temp_len = (strlen(adjective) + strlen(ending) + 1)));
temp = ast_alloca((temp_len = (strlen(adjective) + strlen(ending) + 1)));
snprintf(temp, temp_len, "%s%s", adjective, ending);
return ast_play_and_wait(chan, temp);
}

@ -68,12 +68,12 @@ int setenv(const char *name, const char *value, int overwrite)
unsigned char *buf;
int buflen;
buflen = strlen(name) + strlen(value) + 2;
buf = alloca(buflen);
if (!overwrite && getenv(name))
return 0;
buflen = strlen(name) + strlen(value) + 2;
buf = ast_alloca(buflen);
snprintf(buf, buflen, "%s=%s", name, value);
return putenv(buf);
@ -105,23 +105,19 @@ static char *upper(const char *orig, char *buf, int bufsize)
char *strcasestr(const char *haystack, const char *needle)
{
char *u1, *u2;
char *offset;
int u1len = strlen(haystack) + 1, u2len = strlen(needle) + 1;
u1 = alloca(u1len);
u2 = alloca(u2len);
if (u1 && u2) {
char *offset;
if (u2len > u1len) {
/* Needle bigger than haystack */
return NULL;
}
offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len));
if (offset) {
/* Return the offset into the original string */
return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1)));
} else {
return NULL;
}
if (u2len > u1len) {
/* Needle bigger than haystack */
return NULL;
}
u1 = ast_alloca(u1len);
u2 = ast_alloca(u2len);
offset = strstr(upper(haystack, u1, u1len), upper(needle, u2, u2len));
if (offset) {
/* Return the offset into the original string */
return ((char *)((unsigned long)haystack + (unsigned long)(offset - u1)));
} else {
return NULL;
}

@ -70,7 +70,7 @@ static HOOK_T ssl_read(void *cookie, char *buf, LEN_T len)
static HOOK_T ssl_write(void *cookie, const char *buf, LEN_T len)
{
#if 0
char *s = alloca(len+1);
char *s = ast_alloca(len+1);
strncpy(s, buf, len);
s[len] = '\0';
ast_verb(0, "ssl write size %d <%s>\n", (int)len, s);

@ -215,7 +215,7 @@ static char *handle_cli_threadstorage_show_summary(struct ast_cli_entry *e, int
}
if (!file) {
file = alloca(sizeof(*file));
file = ast_alloca(sizeof(*file));
memset(file, 0, sizeof(*file));
file->name = fn ? to->function : to->file;
AST_LIST_INSERT_TAIL(&file_summary, file, entry);

@ -1029,7 +1029,7 @@ int ast_pthread_create_stack(pthread_t *thread, pthread_attr_t *attr, void *(*st
#endif
if (!attr) {
attr = alloca(sizeof(*attr));
attr = ast_alloca(sizeof(*attr));
pthread_attr_init(attr);
}
@ -1077,7 +1077,7 @@ int ast_pthread_create_detached_stack(pthread_t *thread, pthread_attr_t *attr, v
int res;
if (!attr) {
attr = alloca(sizeof(*attr));
attr = ast_alloca(sizeof(*attr));
pthread_attr_init(attr);
attr_destroy = 1;
}
@ -1941,7 +1941,7 @@ int ast_mkdir(const char *path, int mode)
int len = strlen(path), count = 0, x, piececount = 0;
char *tmp = ast_strdupa(path);
char **pieces;
char *fullpath = alloca(len + 1);
char *fullpath = ast_alloca(len + 1);
int res = 0;
for (ptr = tmp; *ptr; ptr++) {
@ -1950,7 +1950,7 @@ int ast_mkdir(const char *path, int mode)
}
/* Count the components to the directory path */
pieces = alloca(count * sizeof(*pieces));
pieces = ast_alloca(count * sizeof(*pieces));
for (ptr = tmp; *ptr; ptr++) {
if (*ptr == '/') {
*ptr = '\0';

@ -165,7 +165,7 @@ static int pbx_load_module(void)
if (config[0] == '/')
rfilename = (char *)config;
else {
rfilename = alloca(strlen(config) + strlen(ast_config_AST_CONFIG_DIR) + 2);
rfilename = ast_alloca(strlen(config) + strlen(ast_config_AST_CONFIG_DIR) + 2);
sprintf(rfilename, "%s/%s", ast_config_AST_CONFIG_DIR, config);
}
if (access(rfilename,R_OK) != 0) {

@ -1383,9 +1383,7 @@ static struct dundi_hdr *dundi_decrypt(struct dundi_transaction *trans, unsigned
unsigned long bytes;
struct dundi_hdr *h;
unsigned char *decrypt_space;
decrypt_space = alloca(srclen);
if (!decrypt_space)
return NULL;
decrypt_space = ast_alloca(srclen);
decrypt_memcpy(decrypt_space, src->encdata, srclen, src->iv, &trans->dcx);
/* Setup header */
h = (struct dundi_hdr *)dst;
@ -1411,61 +1409,58 @@ static int dundi_encrypt(struct dundi_transaction *trans, struct dundi_packet *p
struct dundi_peer *peer;
unsigned char iv[16];
len = pack->datalen + pack->datalen / 100 + 42;
compress_space = alloca(len);
if (compress_space) {
memset(compress_space, 0, len);
/* We care about everthing save the first 6 bytes of header */
bytes = len;
res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6);
if (res != Z_OK) {
ast_debug(1, "Ouch, compression failed!\n");
compress_space = ast_alloca(len);
memset(compress_space, 0, len);
/* We care about everthing save the first 6 bytes of header */
bytes = len;
res = compress(compress_space, &bytes, pack->data + 6, pack->datalen - 6);
if (res != Z_OK) {
ast_debug(1, "Ouch, compression failed!\n");
return -1;
}
memset(&ied, 0, sizeof(ied));
/* Say who we are */
if (!pack->h->iseqno && !pack->h->oseqno) {
/* Need the key in the first copy */
if (!(peer = find_peer(&trans->them_eid)))
return -1;
}
memset(&ied, 0, sizeof(ied));
/* Say who we are */
if (!pack->h->iseqno && !pack->h->oseqno) {
/* Need the key in the first copy */
if (!(peer = find_peer(&trans->them_eid)))
return -1;
if (update_key(peer))
return -1;
if (!peer->sentfullkey)
ast_set_flag(trans, FLAG_SENDFULLKEY);
/* Append key data */
dundi_ie_append_eid(&ied, DUNDI_IE_EID, &trans->us_eid);
if (ast_test_flag(trans, FLAG_SENDFULLKEY)) {
dundi_ie_append_raw(&ied, DUNDI_IE_SHAREDKEY, peer->txenckey, 128);
dundi_ie_append_raw(&ied, DUNDI_IE_SIGNATURE, peer->txenckey + 128, 128);
} else {
dundi_ie_append_int(&ied, DUNDI_IE_KEYCRC32, peer->us_keycrc32);
}
/* Setup contexts */
trans->ecx = peer->us_ecx;
trans->dcx = peer->us_dcx;
/* We've sent the full key */
peer->sentfullkey = 1;
}
/* Build initialization vector */
build_iv(iv);
/* Add the field, rounded up to 16 bytes */
dundi_ie_append_encdata(&ied, DUNDI_IE_ENCDATA, iv, NULL, ((bytes + 15) / 16) * 16);
/* Copy the data */
if ((ied.pos + bytes) >= sizeof(ied.buf)) {
ast_log(LOG_NOTICE, "Final packet too large!\n");
if (update_key(peer))
return -1;
if (!peer->sentfullkey)
ast_set_flag(trans, FLAG_SENDFULLKEY);
/* Append key data */
dundi_ie_append_eid(&ied, DUNDI_IE_EID, &trans->us_eid);
if (ast_test_flag(trans, FLAG_SENDFULLKEY)) {
dundi_ie_append_raw(&ied, DUNDI_IE_SHAREDKEY, peer->txenckey, 128);
dundi_ie_append_raw(&ied, DUNDI_IE_SIGNATURE, peer->txenckey + 128, 128);
} else {
dundi_ie_append_int(&ied, DUNDI_IE_KEYCRC32, peer->us_keycrc32);
}
encrypt_memcpy(ied.buf + ied.pos, compress_space, bytes, iv, &trans->ecx);
ied.pos += ((bytes + 15) / 16) * 16;
/* Reconstruct header */
pack->datalen = sizeof(struct dundi_hdr);
pack->h->cmdresp = DUNDI_COMMAND_ENCRYPT;
pack->h->cmdflags = 0;
memcpy(pack->h->ies, ied.buf, ied.pos);
pack->datalen += ied.pos;
return 0;
/* Setup contexts */
trans->ecx = peer->us_ecx;
trans->dcx = peer->us_dcx;
/* We've sent the full key */
peer->sentfullkey = 1;
}
/* Build initialization vector */
build_iv(iv);
/* Add the field, rounded up to 16 bytes */
dundi_ie_append_encdata(&ied, DUNDI_IE_ENCDATA, iv, NULL, ((bytes + 15) / 16) * 16);
/* Copy the data */
if ((ied.pos + bytes) >= sizeof(ied.buf)) {
ast_log(LOG_NOTICE, "Final packet too large!\n");
return -1;
}
return -1;
encrypt_memcpy(ied.buf + ied.pos, compress_space, bytes, iv, &trans->ecx);
ied.pos += ((bytes + 15) / 16) * 16;
/* Reconstruct header */
pack->datalen = sizeof(struct dundi_hdr);
pack->h->cmdresp = DUNDI_COMMAND_ENCRYPT;
pack->h->cmdflags = 0;
memcpy(pack->h->ies, ied.buf, ied.pos);
pack->datalen += ied.pos;
return 0;
}
static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned char *newsig, uint32_t keycrc32)
@ -1582,10 +1577,7 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
}
if (datalen) {
bufcpy = alloca(datalen);
if (!bufcpy) {
goto return_cleanup;
}
bufcpy = ast_alloca(datalen);
/* Make a copy for parsing */
memcpy(bufcpy, hdr->ies, datalen);
ast_debug(1, "Got canonical message %d (%d), %d bytes data%s\n", cmd, hdr->oseqno, datalen, final ? " (Final)" : "");
@ -3767,18 +3759,17 @@ static int dundi_precache_internal(const char *context, const char *number, int
nummaps++;
}
if (nummaps) {
maps = alloca(nummaps * sizeof(*maps));
maps = ast_alloca(nummaps * sizeof(*maps));
nummaps = 0;
if (maps) {
AST_LIST_TRAVERSE(&mappings, cur, list) {
if (!strcasecmp(cur->dcontext, context))
maps[nummaps++] = *cur;
}
AST_LIST_TRAVERSE(&mappings, cur, list) {
if (!strcasecmp(cur->dcontext, context))
maps[nummaps++] = *cur;
}
}
AST_LIST_UNLOCK(&peers);
if (!nummaps || !maps)
if (!nummaps) {
return -1;
}
ttlms = DUNDI_FLUFF_TIME + ttl * DUNDI_TTL_TIME;
memset(&dr2, 0, sizeof(dr2));
memset(&dr, 0, sizeof(dr));

@ -303,7 +303,7 @@ static int lua_get_variable_value(lua_State *L)
{
struct ast_channel *chan;
char *value = NULL, *name;
char *workspace = alloca(LUA_BUF_SIZE);
char *workspace = ast_alloca(LUA_BUF_SIZE);
int autoservice;
workspace[0] = '\0';
@ -561,7 +561,7 @@ static int lua_get_variable(lua_State *L)
struct ast_channel *chan;
const char *name = luaL_checkstring(L, 2);
char *value = NULL;
char *workspace = alloca(LUA_BUF_SIZE);
char *workspace = ast_alloca(LUA_BUF_SIZE);
workspace[0] = '\0';
lua_getfield(L, LUA_REGISTRYINDEX, "channel");
@ -1080,7 +1080,7 @@ static char *lua_read_extensions_file(lua_State *L, long *size)
FILE *f;
int error_func;
char *data;
char *path = alloca(strlen(config) + strlen(ast_config_AST_CONFIG_DIR) + 2);
char *path = ast_alloca(strlen(config) + strlen(ast_config_AST_CONFIG_DIR) + 2);
sprintf(path, "%s/%s", ast_config_AST_CONFIG_DIR, config);
if (!(f = fopen(path, "r"))) {

@ -228,52 +228,50 @@ static struct ast_variable *realtime_common(const char *context, const char *ext
char exten[AST_MAX_EXTENSION];
} cache_search = { { .priority = priority, .context = (char *) context }, };
char *buf = ast_strdupa(data);
if (buf) {
/* "Realtime" prefix is stripped off in the parent engine. The
* remaining string is: [[context@]table][/opts] */
char *opts = strchr(buf, '/');
if (opts)
*opts++ = '\0';
table = strchr(buf, '@');
if (table) {
*table++ = '\0';
ctx = buf;
}
ctx = S_OR(ctx, context);
table = S_OR(table, "extensions");
if (!ast_strlen_zero(opts)) {
ast_app_parse_options(switch_opts, &flags, NULL, opts);
}
ast_copy_string(cache_search.exten, exten, sizeof(cache_search.exten));
if (mode == MODE_MATCH && (ce = ao2_find(cache, &cache_search, OBJ_POINTER))) {
var = dup_vars(ce->var);
/* "Realtime" prefix is stripped off in the parent engine. The
* remaining string is: [[context@]table][/opts] */
char *opts = strchr(buf, '/');
if (opts)
*opts++ = '\0';
table = strchr(buf, '@');
if (table) {
*table++ = '\0';
ctx = buf;
}
ctx = S_OR(ctx, context);
table = S_OR(table, "extensions");
if (!ast_strlen_zero(opts)) {
ast_app_parse_options(switch_opts, &flags, NULL, opts);
}
ast_copy_string(cache_search.exten, exten, sizeof(cache_search.exten));
if (mode == MODE_MATCH && (ce = ao2_find(cache, &cache_search, OBJ_POINTER))) {
var = dup_vars(ce->var);
ao2_ref(ce, -1);
} else {
var = realtime_switch_common(table, ctx, exten, priority, mode, flags);
do {
struct ast_variable *new;
/* Only cache matches */
if (mode != MODE_MATCH) {
break;
}
if (!(new = dup_vars(var))) {
break;
}
if (!(ce = ao2_alloc(sizeof(*ce) + strlen(exten) + strlen(context), free_entry))) {
ast_variables_destroy(new);
break;
}
ce->context = ce->exten + strlen(exten) + 1;
strcpy(ce->exten, exten); /* SAFE */
strcpy(ce->context, context); /* SAFE */
ce->priority = priority;
ce->var = new;
ce->when = ast_tvnow();
ao2_link(cache, ce);
pthread_kill(cleanup_thread, SIGURG);
ao2_ref(ce, -1);
} else {
var = realtime_switch_common(table, ctx, exten, priority, mode, flags);
do {
struct ast_variable *new;
/* Only cache matches */
if (mode != MODE_MATCH) {
break;
}
if (!(new = dup_vars(var))) {
break;
}
if (!(ce = ao2_alloc(sizeof(*ce) + strlen(exten) + strlen(context), free_entry))) {
ast_variables_destroy(new);
break;
}
ce->context = ce->exten + strlen(exten) + 1;
strcpy(ce->exten, exten); /* SAFE */
strcpy(ce->context, context); /* SAFE */
ce->priority = priority;
ce->var = new;
ce->when = ast_tvnow();
ao2_link(cache, ce);
pthread_kill(cleanup_thread, SIGURG);
ao2_ref(ce, -1);
} while (0);
}
} while (0);
}
return var;
}
@ -315,7 +313,7 @@ static int realtime_exec(struct ast_channel *chan, const char *context, const ch
if (ast_compat_pbx_realtime) {
char *ptr;
int in = 0;
tmp = alloca(strlen(v->value) * 2 + 1);
tmp = ast_alloca(strlen(v->value) * 2 + 1);
for (ptr = tmp; *v->value; v->value++) {
if (*v->value == ',') {
*ptr++ = '\\';

@ -482,7 +482,7 @@ static void queue_file(const char *filename, time_t when)
time_t now = time(NULL);
if (filename[0] != '/') {
char *fn = alloca(strlen(qdir) + strlen(filename) + 2);
char *fn = ast_alloca(strlen(qdir) + strlen(filename) + 2);
sprintf(fn, "%s/%s", qdir, filename); /* SAFE */
filename = fn;
}

@ -2902,7 +2902,7 @@ void ael2_semantic_check(pval *item, int *arg_errs, int *arg_warns, int *arg_not
if (!item)
return; /* don't check an empty tree */
#ifdef AAL_ARGCHECK
rfilename = alloca(10 + strlen(ast_config_AST_VAR_DIR));
rfilename = ast_alloca(10 + strlen(ast_config_AST_VAR_DIR));
sprintf(rfilename, "%s/applist", ast_config_AST_VAR_DIR);
apps = argdesc_parse(rfilename, &argapp_errs); /* giveth */

@ -1554,10 +1554,11 @@ static enum agi_result launch_ha_netscript(char *agiurl, char *argv[], int *fds)
unsigned short srvport;
/* format of agiurl is "hagi://host.domain[:port][/script/name]" */
if (!(host = ast_strdupa(agiurl + 7))) { /* Remove hagi:// */
if (strlen(agiurl) < 7) { /* Remove hagi:// */
ast_log(LOG_WARNING, "An error occurred parsing the AGI URI: %s", agiurl);
return AGI_RESULT_FAILURE;
}
host = ast_strdupa(agiurl + 7);
/* Strip off any script name */
if ((script = strchr(host, '/'))) {
@ -2477,7 +2478,7 @@ static int handle_exec(struct ast_channel *chan, AGI *agi, int argc, const char
ast_set_flag(chan, AST_FLAG_DISABLE_WORKAROUNDS);
}
if (ast_compat_res_agi && argc >= 3 && !ast_strlen_zero(argv[2])) {
char *compat = alloca(strlen(argv[2]) * 2 + 1), *cptr;
char *compat = ast_alloca(strlen(argv[2]) * 2 + 1), *cptr;
const char *vptr;
for (cptr = compat, vptr = argv[2]; *vptr; vptr++) {
if (*vptr == ',') {

@ -290,7 +290,7 @@ static struct tables *find_table(const char *database, const char *orig_tablenam
if (strchr(schemaname, '\\') || strchr(schemaname, '\'')) {
char *tmp = schemaname, *ptr;
ptr = schemaname = alloca(strlen(tmp) * 2 + 1);
ptr = schemaname = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;
@ -303,7 +303,7 @@ static struct tables *find_table(const char *database, const char *orig_tablenam
if (strchr(tablename, '\\') || strchr(tablename, '\'')) {
char *tmp = tablename, *ptr;
ptr = tablename = alloca(strlen(tmp) * 2 + 1);
ptr = tablename = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;
@ -322,7 +322,7 @@ static struct tables *find_table(const char *database, const char *orig_tablenam
const char *tmp = orig_tablename;
char *ptr;
orig_tablename = ptr = alloca(strlen(tmp) * 2 + 1);
orig_tablename = ptr = ast_alloca(strlen(tmp) * 2 + 1);
for (; *tmp; tmp++) {
if (strchr("\\'", *tmp)) {
*ptr++ = *tmp;

@ -1585,8 +1585,8 @@ static int aji_start_sasl(struct aji_client *client, enum ikssasltype type, char
iks_insert_attrib(x, "xmlns", IKS_NS_XMPP_SASL);
len = strlen(username) + strlen(pass) + 3;
s = alloca(len);
base64 = alloca((len + 2) * 4 / 3);
s = ast_alloca(len);
base64 = ast_alloca((len + 2) * 4 / 3);
iks_insert_attrib(x, "mechanism", "PLAIN");
snprintf(s, len, "%c%s%c%s", 0, username, 0, pass);

@ -98,7 +98,7 @@ AST_TEST_DEFINE(single_ll_tests)
return AST_TEST_FAIL;
}
if (!(bogus = alloca(sizeof(*bogus)))) {
if (!(bogus = ast_alloca(sizeof(*bogus)))) {
return AST_TEST_FAIL;
}

@ -5812,7 +5812,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
whereweare += (len + 3);
if (!var)
var = alloca(VAR_BUF_SIZE);
var = ast_alloca(VAR_BUF_SIZE);
/* Store variable name (and truncate) */
ast_copy_string(var, vars, len + 1);
@ -5820,7 +5820,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
/* Substitute if necessary */
if (needsub) {
if (!ltmp)
ltmp = alloca(VAR_BUF_SIZE);
ltmp = ast_alloca(VAR_BUF_SIZE);
memset(ltmp, 0, VAR_BUF_SIZE);
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1);
@ -5830,7 +5830,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
}
if (!workspace)
workspace = alloca(VAR_BUF_SIZE);
workspace = ast_alloca(VAR_BUF_SIZE);
workspace[0] = '\0';
@ -5887,7 +5887,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
whereweare += (len + 3);
if (!var)
var = alloca(VAR_BUF_SIZE);
var = ast_alloca(VAR_BUF_SIZE);
/* Store variable name (and truncate) */
ast_copy_string(var, vars, len + 1);
@ -5895,7 +5895,7 @@ static void pbx_substitute_variables_helper_full(struct ast_channel *c, struct v
/* Substitute if necessary */
if (needsub) {
if (!ltmp)
ltmp = alloca(VAR_BUF_SIZE);
ltmp = ast_alloca(VAR_BUF_SIZE);
memset(ltmp, 0, VAR_BUF_SIZE);
pbx_substitute_variables_helper_full(c, headp, var, ltmp, VAR_BUF_SIZE - 1);

Loading…
Cancel
Save