summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-21 23:08:53 +0200
committerdimitri staessens <dimitri.staessens@intec.ugent.be>2016-08-21 23:31:42 +0200
commit9c946366fcd477b285b4421c324162a10aa300b6 (patch)
tree2ca0e58bbf99625599f431761248771eb47bee78
parent29adff2f68ce990ebaed3d0c9c1baf50ef474f4f (diff)
downloadouroboros-9c946366fcd477b285b4421c324162a10aa300b6.tar.gz
ouroboros-9c946366fcd477b285b4421c324162a10aa300b6.zip
ipcpd: Fix potential memleaks
-rw-r--r--src/ipcpd/ipcp.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/ipcpd/ipcp.c b/src/ipcpd/ipcp.c
index cc77af89..4f3e6799 100644
--- a/src/ipcpd/ipcp.c
+++ b/src/ipcpd/ipcp.c
@@ -127,6 +127,7 @@ void * ipcp_main_loop(void * o)
struct dif_config conf;
char * sock_path;
+ char * msg_name_dup;
struct timeval tv = {(SOCKET_TIMEOUT / 1000),
(SOCKET_TIMEOUT % 1000) * 1000};
@@ -188,7 +189,7 @@ void * ipcp_main_loop(void * o)
}
conf_msg = msg->conf;
conf.type = conf_msg->ipcp_type;
- conf.dif_name = conf_msg->dif_name;
+ conf.dif_name = strdup(conf_msg->dif_name);
if (conf.dif_name == NULL) {
ret_msg.has_result = true;
ret_msg.result = -1;
@@ -217,6 +218,8 @@ void * ipcp_main_loop(void * o)
ret_msg.has_result = true;
ret_msg.result = _ipcp->ops->ipcp_bootstrap(&conf);
+ if (ret_msg.result < 0)
+ free(conf.dif_name);
break;
case IPCP_MSG_CODE__IPCP_ENROLL:
if (_ipcp->ops->ipcp_enroll == NULL) {
@@ -232,9 +235,12 @@ void * ipcp_main_loop(void * o)
LOG_ERR("Ap_reg unsupported.");
break;
}
+ msg_name_dup = strdup(msg->name);
ret_msg.has_result = true;
ret_msg.result =
- _ipcp->ops->ipcp_name_reg(strdup(msg->name));
+ _ipcp->ops->ipcp_name_reg(msg_name_dup);
+ if (ret_msg.result < 0)
+ free(msg_name_dup);
break;
case IPCP_MSG_CODE__IPCP_NAME_UNREG:
if (_ipcp->ops->ipcp_name_unreg == NULL) {