Module: kamailio
Branch: master
Commit: 631aab425e1f3908d9e1b044c2a0715f457655ac
URL:
https://github.com/kamailio/kamailio/commit/631aab425e1f3908d9e1b044c2a0715…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2023-06-15T11:31:59+02:00
cdp: safety check closing fd for error cases
---
Modified: src/modules/cdp/cdp_mod.c
Modified: src/modules/cdp/receiver.c
---
Diff:
https://github.com/kamailio/kamailio/commit/631aab425e1f3908d9e1b044c2a0715…
Patch:
https://github.com/kamailio/kamailio/commit/631aab425e1f3908d9e1b044c2a0715…
---
diff --git a/src/modules/cdp/cdp_mod.c b/src/modules/cdp/cdp_mod.c
index 2669a2b93c..8bac55c50d 100644
--- a/src/modules/cdp/cdp_mod.c
+++ b/src/modules/cdp/cdp_mod.c
@@ -78,7 +78,9 @@ static int w_cdp_has_app2(sip_msg_t *msg, char *vendor, char *appid);
static int w_cdp_has_app(sip_msg_t *msg, char *appid, char *param);
+/* clang-format off */
#define EXP_FUNC(NAME) {#NAME, (cmd_function)NAME, NO_SCRIPT, 0, 0}
+/* clang-format on */
/**
* Exported functions. This is the API available for use from other modules.
diff --git a/src/modules/cdp/receiver.c b/src/modules/cdp/receiver.c
index 9124c4eef4..61d932743a 100644
--- a/src/modules/cdp/receiver.c
+++ b/src/modules/cdp/receiver.c
@@ -161,8 +161,10 @@ static void close_send_pipe(serviced_peer_t *sp)
{
int tmp;
if(sp->send_pipe_name.s) {
- close(sp->send_pipe_fd);
- close(sp->send_pipe_fd_out);
+ if(sp->send_pipe_fd >= 0)
+ close(sp->send_pipe_fd);
+ if(sp->send_pipe_fd_out >= 0)
+ close(sp->send_pipe_fd_out);
tmp = remove(sp->send_pipe_name.s);
if(tmp == -1) {
LM_ERR("could not remove send pipe\n");