mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 20:20:07 +00:00
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
This commit is contained in:
@@ -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;
|
||||
|
Reference in New Issue
Block a user