mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-15 08:44:14 +00:00
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 ........ Merged revisions 370643 from http://svn.asterisk.org/svn/asterisk/branches/10 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@370655 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -5657,7 +5657,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);
|
||||
}
|
||||
@@ -13829,7 +13829,7 @@ static void state_notify_build_xml(struct state_notify_data *data, int full, con
|
||||
cid_num = S_COR(ast_channel_caller(caller)->id.number.valid,
|
||||
ast_channel_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(ast_channel_caller(caller)->id.name.valid,
|
||||
@@ -13838,7 +13838,7 @@ static void state_notify_build_xml(struct state_notify_data *data, int full, con
|
||||
connected_num = S_COR(ast_channel_connected(caller)->id.number.valid,
|
||||
ast_channel_connected(caller)->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(ast_channel_connected(caller)->id.name.valid,
|
||||
@@ -25025,7 +25025,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;
|
||||
@@ -27037,7 +27038,7 @@ static int handle_incoming(struct sip_pvt *p, struct sip_request *req, struct as
|
||||
int data_size = sizeof(*cause_code);
|
||||
/* size of the string making up the cause code is "SIP " + cause length */
|
||||
data_size += 4 + strlen(REQ_OFFSET_TO_STR(req, rlpart2));
|
||||
cause_code = alloca(data_size);
|
||||
cause_code = ast_alloca(data_size);
|
||||
|
||||
ast_copy_string(cause_code->chan_name, ast_channel_name(p->owner), AST_CHANNEL_NAME);
|
||||
|
||||
@@ -31734,7 +31735,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) {
|
||||
|
Reference in New Issue
Block a user