summaryrefslogtreecommitdiff
path: root/apps/app_dial.c
diff options
context:
space:
mode:
authorMark Michelson <mmichelson@digium.com>2012-10-15 21:25:29 +0000
committerMark Michelson <mmichelson@digium.com>2012-10-15 21:25:29 +0000
commite9ab568f88b48c1129c79fa2f008b5be72399bc6 (patch)
treef10049c3dc1174a601f224397b8ed6b04c9f6bab /apps/app_dial.c
parente41a591dfc6c199602d2a49ef9a139ec1ad054a7 (diff)
Fix some potential misuses of ast_str in the code.
Passing an ast_str pointer by value that then calls ast_str_set(), ast_str_set_va(), ast_str_append(), or ast_str_append_va() can result in the pointer originally passed by value being invalidated if the ast_str had to be reallocated. This fixes places in the code that do this. Only the example in ccss.c could result in pointer invalidation though since the other cases use a stack-allocated ast_str and cannot be reallocated. I've also updated the doxygen in strings.h to include notes about potential misuse of the functions mentioned previously. Review: https://reviewboard.asterisk.org/r/2161 ........ Merged revisions 375025 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 375026 from http://svn.asterisk.org/svn/asterisk/branches/10 ........ Merged revisions 375027 from http://svn.asterisk.org/svn/asterisk/branches/11 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@375044 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'apps/app_dial.c')
-rw-r--r--apps/app_dial.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/apps/app_dial.c b/apps/app_dial.c
index 6c56e39ed..310326dc1 100644
--- a/apps/app_dial.c
+++ b/apps/app_dial.c
@@ -709,7 +709,7 @@ struct chanlist {
AST_LIST_HEAD_NOLOCK(dial_head, chanlist);
-static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str *featurecode);
+static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode);
static void chanlist_free(struct chanlist *outgoing)
{
@@ -1606,7 +1606,7 @@ static struct ast_channel *wait_for_answer(struct ast_channel *in,
}
if (ast_test_flag64(peerflags, OPT_CALLER_HANGUP) &&
- detect_disconnect(in, f->subclass.integer, featurecode)) {
+ detect_disconnect(in, f->subclass.integer, &featurecode)) {
ast_verb(3, "User requested call disconnect.\n");
*to = 0;
strcpy(pa->status, "CANCEL");
@@ -1721,18 +1721,18 @@ skip_frame:;
return peer;
}
-static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str *featurecode)
+static int detect_disconnect(struct ast_channel *chan, char code, struct ast_str **featurecode)
{
struct ast_flags features = { AST_FEATURE_DISCONNECT }; /* only concerned with disconnect feature */
struct ast_call_feature feature = { 0, };
int res;
- ast_str_append(&featurecode, 1, "%c", code);
+ ast_str_append(featurecode, 1, "%c", code);
- res = ast_feature_detect(chan, &features, ast_str_buffer(featurecode), &feature);
+ res = ast_feature_detect(chan, &features, ast_str_buffer(*featurecode), &feature);
if (res != AST_FEATURE_RETURN_STOREDIGITS) {
- ast_str_reset(featurecode);
+ ast_str_reset(*featurecode);
}
if (feature.feature_mask & AST_FEATURE_DISCONNECT) {
return 1;