aboutsummaryrefslogtreecommitdiffstats
path: root/pbx
diff options
context:
space:
mode:
authorrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 16:34:05 +0000
committerrussell <russell@f38db490-d61c-443f-a65b-d21fe96a405b>2007-09-18 16:34:05 +0000
commit311d8c0f6c4b0556a8de0ac78d459d5a217f6bf4 (patch)
tree965fabf298aed407220780ef2baffdfd3e806e20 /pbx
parenta6f3537fbb30d12362fc2e5bbea1e95a4efee167 (diff)
Merged revisions 82802 via svnmerge from
https://origsvn.digium.com/svn/asterisk/branches/1.4 ........ r82802 | russell | 2007-09-18 11:31:01 -0500 (Tue, 18 Sep 2007) | 4 lines When copying the contents from the wildcard peer, do a deep copy instead of shallow copy so that it doesn't crash when beging destroyed. (closes issue #10546, patch by me) ........ git-svn-id: http://svn.digium.com/svn/asterisk/trunk@82803 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rw-r--r--pbx/pbx_dundi.c32
1 files changed, 31 insertions, 1 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c
index 9df585ab7..7e91124af 100644
--- a/pbx/pbx_dundi.c
+++ b/pbx/pbx_dundi.c
@@ -1527,6 +1527,36 @@ static int check_key(struct dundi_peer *peer, unsigned char *newkey, unsigned ch
return 1;
}
+static void deep_copy_peer(struct dundi_peer *peer_dst, const struct dundi_peer *peer_src)
+{
+ struct permission *cur, *perm;
+
+ memcpy(peer_dst, peer_src, sizeof(*peer_dst));
+
+ memset(&peer_dst->permit, 0, sizeof(peer_dst->permit));
+ memset(&peer_dst->include, 0, sizeof(peer_dst->permit));
+
+ AST_LIST_TRAVERSE(&peer_src->permit, cur, list) {
+ if (!(perm = ast_calloc(1, sizeof(*perm) + strlen(cur->name) + 1)))
+ continue;
+
+ perm->allow = cur->allow;
+ strcpy(perm->name, cur->name);
+
+ AST_LIST_INSERT_HEAD(&peer_dst->permit, perm, list);
+ }
+
+ AST_LIST_TRAVERSE(&peer_src->include, cur, list) {
+ if (!(perm = ast_calloc(1, sizeof(*perm) + strlen(cur->name) + 1)))
+ continue;
+
+ perm->allow = cur->allow;
+ strcpy(perm->name, cur->name);
+
+ AST_LIST_INSERT_HEAD(&peer_dst->include, perm, list);
+ }
+}
+
static int handle_command_response(struct dundi_transaction *trans, struct dundi_hdr *hdr, int datalen, int encrypted)
{
/* Handle canonical command / response */
@@ -1630,7 +1660,7 @@ static int handle_command_response(struct dundi_transaction *trans, struct dundi
/* copy any_peer into a new peer object */
peer = ast_calloc(1, sizeof(*peer));
if (peer) {
- memcpy(peer, any_peer, sizeof(*peer));
+ deep_copy_peer(peer, any_peer);
/* set EID to remote EID */
peer->eid = *ies.eids[0];