mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-29 18:19:30 +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:
10
main/event.c
10
main/event.c
@@ -480,7 +480,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));
|
||||
@@ -504,7 +504,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;
|
||||
@@ -1157,7 +1157,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) {
|
||||
@@ -1229,7 +1229,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));
|
||||
@@ -1252,7 +1252,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;
|
||||
|
Reference in New Issue
Block a user