[sr-dev] git:5.3:6d1abb35: ims_ipsec_pcscf: closing mnl_socket in some exceptional situations

Henning Westerholt hw at skalatan.de
Thu Nov 7 18:08:19 CET 2019


Module: kamailio
Branch: 5.3
Commit: 6d1abb352c772caf164486854a2609ca67a0142b
URL: https://github.com/kamailio/kamailio/commit/6d1abb352c772caf164486854a2609ca67a0142b

Author: Stanislav S. Litvinenko <litvinenko at protei.ru>
Committer: Henning Westerholt <hw at skalatan.de>
Date: 2019-11-07T18:08:09+01:00

ims_ipsec_pcscf: closing mnl_socket in some exceptional situations

- fix leak socket when error handling errors in creation or destruction ipsec tunnel

(cherry picked from commit 575102bef5418ddfef2f619f22dd827183eef8af)

---

Modified: src/modules/ims_ipsec_pcscf/cmd.c

---

Diff:  https://github.com/kamailio/kamailio/commit/6d1abb352c772caf164486854a2609ca67a0142b.diff
Patch: https://github.com/kamailio/kamailio/commit/6d1abb352c772caf164486854a2609ca67a0142b.patch

---

diff --git a/src/modules/ims_ipsec_pcscf/cmd.c b/src/modules/ims_ipsec_pcscf/cmd.c
index c27335126b..11673582ad 100644
--- a/src/modules/ims_ipsec_pcscf/cmd.c
+++ b/src/modules/ims_ipsec_pcscf/cmd.c
@@ -338,15 +338,18 @@ static int create_ipsec_tunnel(const struct ip_addr *remote_addr, ipsec_t* s)
     if(remote_addr->af == AF_INET){
         if(str2ipbuf(&ipsec_listen_addr, &ipsec_addr) < 0){
             LM_ERR("Unable to convert ipsec addr4 [%.*s]\n", ipsec_listen_addr.len, ipsec_listen_addr.s);
+            close_mnl_socket(sock);
             return 0;
         }
     } else if(remote_addr->af == AF_INET6){
         if(str2ip6buf(&ipsec_listen_addr6, &ipsec_addr) < 0){
             LM_ERR("Unable to convert ipsec addr6 [%.*s]\n", ipsec_listen_addr6.len, ipsec_listen_addr6.s);
+            close_mnl_socket(sock);
             return 0;
         }
     } else {
         LM_ERR("Unsupported AF %d\n", remote_addr->af);
+        close_mnl_socket(sock);
         return 0;
     }
 
@@ -355,6 +358,7 @@ static int create_ipsec_tunnel(const struct ip_addr *remote_addr, ipsec_t* s)
     memset(remote_addr_str, 0, sizeof(remote_addr_str));
     if(inet_ntop(remote_addr->af, remote_addr->u.addr, remote_addr_str, sizeof(remote_addr_str)) == NULL) {
         LM_CRIT("Error converting remote IP address: %s\n", strerror(errno));
+        close_mnl_socket(sock);
         return -1;
     }
 
@@ -401,6 +405,7 @@ static int destroy_ipsec_tunnel(str remote_addr, ipsec_t* s, unsigned short rece
     // convert 'remote_addr' ip string to ip_addr_t
     if(str2ipxbuf(&remote_addr, &ip_addr) < 0){
         LM_ERR("Unable to convert remote address [%.*s]\n", remote_addr.len, remote_addr.s);
+        close_mnl_socket(sock);
         return -1;
     }
 




More information about the sr-dev mailing list