Module: kamailio
Branch: master
Commit: 993c036bb185f6053a3a2f0486be30398918a87c
URL:
https://github.com/kamailio/kamailio/commit/993c036bb185f6053a3a2f0486be303…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2022-05-04T14:55:01+02:00
cdp: close socket in case of error
---
Modified: src/modules/cdp/receiver.c
---
Diff:
https://github.com/kamailio/kamailio/commit/993c036bb185f6053a3a2f0486be303…
Patch:
https://github.com/kamailio/kamailio/commit/993c036bb185f6053a3a2f0486be303…
---
diff --git a/src/modules/cdp/receiver.c b/src/modules/cdp/receiver.c
index 0bff4131d3..692cc363ae 100644
--- a/src/modules/cdp/receiver.c
+++ b/src/modules/cdp/receiver.c
@@ -844,7 +844,7 @@ int receive_loop(peer *original_peer)
*/
int peer_connect(peer *p)
{
- int sock;
+ int sock = -1;
int tmp = 0;
unsigned int option = 1;
@@ -922,17 +922,20 @@ int peer_connect(peer *p)
if (valopt) {
LM_ERR("peer_connect(): Error opening connection to to %s port %s
>%s\n",host,serv,strerror(valopt));
close(sock);
+ sock = -1;
continue;
}
}else{
LM_ERR("peer_connect(): Timeout or error opening connection to to %s port %s
>%s\n",host,serv,strerror(errno));
close(sock);
+ sock = -1;
continue;
}
}
}else{
LM_ERR("peer_connect(): Error opening connection to to %s port %s
>%s\n",host,serv,strerror(errno));
close(sock);
+ sock = -1;
continue;
}
@@ -956,7 +959,6 @@ int peer_connect(peer *p)
if (!send_fd(p->fd_exchange_pipe,sock,p)){
LM_ERR("peer_connect(): [%.*s] Error sending fd to respective
receiver\n",p->fqdn.len,p->fqdn.s);
- close(sock);
goto error;
}
@@ -967,6 +969,7 @@ int peer_connect(peer *p)
error:
if (res) freeaddrinfo(res);
if (sainfo) freeaddrinfo(sainfo);
+ if (sock!=-1) close(sock);
return -1;
}