[asterisk-commits] mmichelson: branch mmichelson/digit_manipulation r195837 - /team/mmichelson/d...
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Wed May 20 17:03:10 CDT 2009
Author: mmichelson
Date: Wed May 20 17:03:07 2009
New Revision: 195837
URL: http://svn.asterisk.org/svn-view/asterisk?view=rev&rev=195837
Log:
Switch from ast_strdupa to using a static char buffer.
Using ast_strdupa inside a potentially long-running loop
can cause stack space shortage. While it's not likely to occur
here, I don't want to take any chances.
Modified:
team/mmichelson/digit_manipulation/apps/app_dial.c
Modified: team/mmichelson/digit_manipulation/apps/app_dial.c
URL: http://svn.asterisk.org/svn-view/asterisk/team/mmichelson/digit_manipulation/apps/app_dial.c?view=diff&rev=195837&r1=195836&r2=195837
==============================================================================
--- team/mmichelson/digit_manipulation/apps/app_dial.c (original)
+++ team/mmichelson/digit_manipulation/apps/app_dial.c Wed May 20 17:03:07 2009
@@ -868,6 +868,8 @@
#endif
struct ast_party_connected_line connected_caller;
struct ast_str *featurecode = ast_str_alloca(FEATURE_MAX_LEN + 1);
+ char macro[AST_MAX_CONTEXT];
+ char macro_args[512]; /*XXX Big enough? */
ast_party_connected_line_init(&connected_caller);
if (single) {
@@ -934,12 +936,12 @@
ast_verb(3, "%s answered %s\n", c->name, in->name);
if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
if (o->connected.id.number) {
- const char * const macro = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO"), ""));
- const char * const args = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS"), ""));
- ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, args);
+ ast_copy_string(macro, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO"), ""), sizeof(macro));
+ ast_copy_string(macro_args, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS"), ""), sizeof(macro_args));
+ ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, macro_args);
if (!ast_strlen_zero(macro)) {
ast_party_connected_line_copy(&in->connected, &o->connected);
- ast_app_run_macro(c, in, macro, args);
+ ast_app_run_macro(c, in, macro, macro_args);
ast_channel_update_connected_line(in, &in->connected);
} else {
ast_channel_update_connected_line(in, &o->connected);
@@ -993,12 +995,12 @@
ast_verb(3, "%s answered %s\n", c->name, in->name);
if (!single && !ast_test_flag64(peerflags, OPT_IGNORE_CONNECTEDLINE)) {
if (o->connected.id.number) {
- const char * const macro = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO"), ""));
- const char * const args = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS"), ""));
- ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, args);
+ ast_copy_string(macro, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO"), ""), sizeof(macro));
+ ast_copy_string(macro_args, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS"), ""), sizeof(macro_args));
+ ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, macro_args);
if (!ast_strlen_zero(macro)) {
ast_party_connected_line_copy(&in->connected, &o->connected);
- ast_app_run_macro(c, in, macro, args);
+ ast_app_run_macro(c, in, macro, macro_args);
ast_channel_update_connected_line(in, &in->connected);
} else {
ast_channel_update_connected_line(in, &o->connected);
@@ -1091,13 +1093,13 @@
ast_party_connected_line_set(&o->connected, &connected);
ast_party_connected_line_free(&connected);
} else {
- const char * const macro = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO"), ""));
- const char * const args = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS"), ""));
- ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, args);
+ ast_copy_string(macro, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO"), ""), sizeof(macro));
+ ast_copy_string(macro_args, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLER_SEND_MACRO_ARGS"), ""), sizeof(macro_args));
+ ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, macro_args);
ast_verb(3, "%s connected line has changed, passing it to %s\n", c->name, in->name);
if (!ast_strlen_zero(macro)) {
ast_connected_line_parse_data(f->data.ptr, f->datalen, &in->connected);
- ast_app_run_macro(c, in, macro, args);
+ ast_app_run_macro(c, in, macro, macro_args);
ast_channel_update_connected_line(in, &in->connected);
} else {
ast_indicate_data(in, AST_CONTROL_CONNECTED_LINE, f->data.ptr, f->datalen);
@@ -1231,12 +1233,12 @@
ast_verb(3, "%s requested special control %d, passing it to %s\n", in->name, f->subclass, outgoing->chan->name);
ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen);
} else if (f->subclass == AST_CONTROL_CONNECTED_LINE) {
- const char * const macro = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLEE_SEND_MACRO"), ""));
- const char * const args = ast_strdupa(S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS"), ""));
- ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, args);
+ ast_copy_string(macro, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLEE_SEND_MACRO"), ""), sizeof(macro));
+ ast_copy_string(macro_args, S_OR(pbx_builtin_getvar_helper(in, "CONNECTED_LINE_CALLEE_SEND_MACRO_ARGS"), ""), sizeof(macro_args));
+ ast_log(LOG_NOTICE, "macro is %s and args is %s\n", macro, macro_args);
if (!ast_strlen_zero(macro)) {
ast_connected_line_parse_data(f->data.ptr, f->datalen, &outgoing->chan->connected);
- ast_app_run_macro(in, outgoing->chan, macro, args);
+ ast_app_run_macro(in, outgoing->chan, macro, macro_args);
ast_channel_update_connected_line(outgoing->chan, &outgoing->chan->connected);
} else {
ast_indicate_data(outgoing->chan, f->subclass, f->data.ptr, f->datalen);
More information about the asterisk-commits
mailing list