]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
chan_sip: Fix leak using contact ACL
authorGiuseppe Sucameli <sucameli@netresults.it>
Wed, 5 Dec 2018 00:00:40 +0000 (01:00 +0100)
committerSean Bright <sean.bright@gmail.com>
Fri, 7 Dec 2018 16:58:03 +0000 (11:58 -0500)
Free old peer's contactacl before overwrite it within build_peer.

ASTERISK-28194

Change-Id: Ie580db6494e50cee0e2a44b38e568e34116ff54c

channels/chan_sip.c

index d90c1c713567520d7059081147dbae439fd8c97c..e1f6f13301ae360c097d4bbe7845b7c570f7bb9e 100644 (file)
@@ -5267,6 +5267,7 @@ static void sip_destroy_peer(struct sip_peer *peer)
 
        register_peer_exten(peer, FALSE);
        ast_free_acl_list(peer->acl);
+       ast_free_acl_list(peer->contactacl);
        ast_free_acl_list(peer->directmediaacl);
        if (peer->selfdestruct)
                ast_atomic_fetchadd_int(&apeerobjs, -1);
@@ -21036,6 +21037,7 @@ static char *_sip_show_peer(int type, int fd, struct mansession *s, const struct
                ast_cli(fd, "  Force rport  : %s\n", force_rport_string(peer->flags));
                ast_cli(fd, "  Symmetric RTP: %s\n", comedia_string(peer->flags));
                ast_cli(fd, "  ACL          : %s\n", AST_CLI_YESNO(ast_acl_list_is_empty(peer->acl) == 0));
+               ast_cli(fd, "  ContactACL   : %s\n", AST_CLI_YESNO(ast_acl_list_is_empty(peer->contactacl) == 0));
                ast_cli(fd, "  DirectMedACL : %s\n", AST_CLI_YESNO(ast_acl_list_is_empty(peer->directmediaacl) == 0));
                ast_cli(fd, "  T.38 support : %s\n", AST_CLI_YESNO(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT)));
                ast_cli(fd, "  T.38 EC mode : %s\n", faxec2str(ast_test_flag(&peer->flags[1], SIP_PAGE2_T38SUPPORT)));
@@ -31280,6 +31282,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v_head
        struct ast_variable *v = v_head;
        struct sip_peer *peer = NULL;
        struct ast_acl_list *oldacl = NULL;
+       struct ast_acl_list *oldcontactacl = NULL;
        struct ast_acl_list *olddirectmediaacl = NULL;
        int found = 0;
        int firstpass = 1;
@@ -31359,6 +31362,8 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v_head
        if (firstpass) {
                oldacl = peer->acl;
                peer->acl = NULL;
+               oldcontactacl = peer->contactacl;
+               peer->contactacl = NULL;
                olddirectmediaacl = peer->directmediaacl;
                peer->directmediaacl = NULL;
                set_peer_defaults(peer);        /* Set peer defaults */
@@ -32022,6 +32027,7 @@ static struct sip_peer *build_peer(const char *name, struct ast_variable *v_head
        peer->the_mark = 0;
 
        oldacl = ast_free_acl_list(oldacl);
+       oldcontactacl = ast_free_acl_list(oldcontactacl);
        olddirectmediaacl = ast_free_acl_list(olddirectmediaacl);
        if (!ast_strlen_zero(peer->callback)) { /* build string from peer info */
                char *reg_string;