diff options
author | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-18 16:31:01 +0000 |
---|---|---|
committer | russell <russell@f38db490-d61c-443f-a65b-d21fe96a405b> | 2007-09-18 16:31:01 +0000 |
commit | f576583b0ad67b8580f98d717e6c78099471a6dc (patch) | |
tree | df460ebf9ec250f2439af70e065a22884d583cf9 /pbx | |
parent | 56bc9423d23939e9dd624d468e1eda383fcc0f48 (diff) |
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/branches/1.4@82802 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'pbx')
-rw-r--r-- | pbx/pbx_dundi.c | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/pbx/pbx_dundi.c b/pbx/pbx_dundi.c index 2f484242a..8384b4d94 100644 --- a/pbx/pbx_dundi.c +++ b/pbx/pbx_dundi.c @@ -1505,6 +1505,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 */ @@ -1607,7 +1637,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]; |