summaryrefslogtreecommitdiff
path: root/channels
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 /channels
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 'channels')
-rw-r--r--channels/chan_iax2.c22
1 files changed, 11 insertions, 11 deletions
diff --git a/channels/chan_iax2.c b/channels/chan_iax2.c
index b6b7e97c1..be0f2676b 100644
--- a/channels/chan_iax2.c
+++ b/channels/chan_iax2.c
@@ -1597,19 +1597,19 @@ static int send_ping(const void *data)
return 0;
}
-static void encmethods_to_str(int e, struct ast_str *buf)
+static void encmethods_to_str(int e, struct ast_str **buf)
{
- ast_str_set(&buf, 0, "(");
+ ast_str_set(buf, 0, "(");
if (e & IAX_ENCRYPT_AES128) {
- ast_str_append(&buf, 0, "aes128");
+ ast_str_append(buf, 0, "aes128");
}
if (e & IAX_ENCRYPT_KEYROTATE) {
- ast_str_append(&buf, 0, ",keyrotate");
+ ast_str_append(buf, 0, ",keyrotate");
}
- if (ast_str_strlen(buf) > 1) {
- ast_str_append(&buf, 0, ")");
+ if (ast_str_strlen(*buf) > 1) {
+ ast_str_append(buf, 0, ")");
} else {
- ast_str_set(&buf, 0, "No");
+ ast_str_set(buf, 0, "No");
}
}
@@ -3829,7 +3829,7 @@ static char *handle_cli_iax2_show_peer(struct ast_cli_entry *e, int cmd, struct
ast_sockaddr_to_sin(&peer->addr, &peer_addr);
- encmethods_to_str(peer->encmethods, encmethods);
+ encmethods_to_str(peer->encmethods, &encmethods);
ast_cli(a->fd, "\n\n");
ast_cli(a->fd, " * Name : %s\n", peer->name);
ast_cli(a->fd, " Description : %s\n", peer->description);
@@ -6811,7 +6811,7 @@ static int __iax2_show_peers(int fd, int *total, struct mansession *s, const int
else
ast_copy_string(name, peer->name, sizeof(name));
- encmethods_to_str(peer->encmethods, encmethods);
+ encmethods_to_str(peer->encmethods, &encmethods);
retstatus = peer_status(peer, status, sizeof(status));
if (retstatus > 0)
online_peers++;
@@ -7116,7 +7116,7 @@ static int manager_iax2_show_peer_list(struct mansession *s, const struct messag
i = ao2_iterator_init(peers, 0);
for (; (peer = ao2_iterator_next(&i)); peer_unref(peer)) {
- encmethods_to_str(peer->encmethods, encmethods);
+ encmethods_to_str(peer->encmethods, &encmethods);
astman_append(s, "Event: PeerEntry\r\n%sChanneltype: IAX\r\n", idtext);
if (!ast_strlen_zero(peer->username)) {
astman_append(s, "ObjectName: %s\r\nObjectUsername: %s\r\n", peer->name, peer->username);
@@ -14781,7 +14781,7 @@ static int peers_data_provider_get(const struct ast_data_search *search,
ast_data_add_bool(data_peer, "dynamic", ast_test_flag64(peer, IAX_DYNAMIC));
- encmethods_to_str(peer->encmethods, encmethods);
+ encmethods_to_str(peer->encmethods, &encmethods);
ast_data_add_str(data_peer, "encryption", peer->encmethods ? ast_str_buffer(encmethods) : "no");
peer_unref(peer);