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: https://origsvn.digium.com/svn/asterisk/trunk@82803 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
Russell Bryant 2007-09-18 16:34:05 +00:00
parent 9a5f7c5764
commit 3d7cf301d8
1 changed files with 31 additions and 1 deletions

View File

@ -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];