diff options
author | Kinsey Moore <kmoore@digium.com> | 2012-07-31 20:21:43 +0000 |
---|---|---|
committer | Kinsey Moore <kmoore@digium.com> | 2012-07-31 20:21:43 +0000 |
commit | 9b16c8b0f6c3b6310e303411421bfcb16b26c3c4 (patch) | |
tree | 273c31a834a21bd2239ec6b83cd35c602ea25d26 /main/features.c | |
parent | 6c23a60f802e7708389b1a6463a40dc0500512bd (diff) |
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
Diffstat (limited to 'main/features.c')
-rw-r--r-- | main/features.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/main/features.c b/main/features.c index dd62c0c7f..5d0f8ec5d 100644 --- a/main/features.c +++ b/main/features.c @@ -857,7 +857,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>", ast_channel_name(chan), seq_num) + 1; - chan_name = alloca(len); + chan_name = ast_alloca(len); snprintf(chan_name, len, "%s<XFER_%x>", ast_channel_name(chan), seq_num); ast_channel_unlock(chan); @@ -2289,8 +2289,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 { @@ -2299,8 +2299,8 @@ static int builtin_automonitor(struct ast_channel *chan, struct ast_channel *pee callee_chan_id = ast_strdupa(S_COR(ast_channel_caller(callee_chan)->id.number.valid, ast_channel_caller(callee_chan)->id.number.str, ast_channel_name(callee_chan))); 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); } @@ -2401,8 +2401,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 { @@ -2411,8 +2411,8 @@ static int builtin_automixmonitor(struct ast_channel *chan, struct ast_channel * callee_chan_id = ast_strdupa(S_COR(ast_channel_caller(callee_chan)->id.number.valid, ast_channel_caller(callee_chan)->id.number.str, ast_channel_name(callee_chan))); 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")); } @@ -3884,7 +3884,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; } |